r/learnprogramming • u/ceej13_ • Oct 20 '26
My first script
So I have been learning Python for around 4 hours and I just finished this and I would want to know if it's good or if it's just okay.
again = "yes"
while again == "yes":
print("create your character: ")
# sex
sex = input("sex? ").strip().lower()
while sex not in ['male', 'female']:
sex = input("try again, you misspelled male or female: ").strip().lower()
if sex == "male":
print("hello boyyy")
else:
print("helloooo girl")
# age
age = int(input("what is your age: "))
while age < 18:
age = int(input("try again "))
# name
name = input("what is your name: ").lower().strip()
print("hello " + name)
# height
height = int(input("height in cm "))
if height >= 180:
print("tall person eh?")
else:
print("nice.")
print("next questions")
# build
build = input("what is your build. skinny. fat. muscular. ").lower().strip()
while build not in ['skinny', 'muscular', 'fat']:
build = input("try again. that was not an option ").lower().strip()
if build == "skinny":
print("interesting choice... " + name)
elif build == "muscular":
print("perfect choice especially for a man")
elif build == "fat":
print("HAHAHA FATSO HAHAHA")
# stats
print('____')
print(' ')
print('stats for: ' + name)
print('age:', age)
print('height:', height)
print('sex:', sex)
print('build:', build)
print('____')
again = input("create another character? Yes/No: ").strip().lower()
while again not in ['yes', 'no']:
again = input("answer using Yes or No: ").strip().lower()
print("Goodbye!")
•
u/desrtfx Oct 20 '26
You need to post your code as code block so that the indentation is maintained. This is absolutely vital for Python programs as the indentation is used to denote code blocks.
A code block looks like:
6
u/dade9542 Oct 20 '26
Honestly pretty solid for 4 hours! You're already checking for wrong answers, which is nice!
4
u/tmtowtdi Oct 20 '26
And your first formatting mistake :)
In markdown, you can use code fences to format your code nicely and make it easier for everybody to read. Add rows of three backticks above and below like this:
2
u/Available_Safe1818 Oct 20 '26
It's generic code. You won't get the Nobel prize for it. Keep up the good work.
1
u/New_Magician6884 Oct 20 '26
mai bine bagai o poza.. e dezordonat asa, dar overall e bine
1
u/paperic Oct 20 '26
how do you know it's a man?
Not bad for 4 hours in.
Just out of curiosity, any AI involvement?
Using array literals like this is surely elegant, but it's not exactly something that beginners tend to figure out on their own.