r/learnprogramming • u/ceej13_ • 1d ago
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!")
5
u/dade9542 1d ago
Honestly pretty solid for 4 hours! You're already checking for wrong answers, which is nice!
3
u/tmtowtdi 1d ago
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:
```
print "Hello, World!";
```
2
u/Available_Safe1818 1d ago
It's generic code. You won't get the Nobel prize for it. Keep up the good work.
3
u/ceej13_ 1d ago
Thanks but I never said I was doing rocket science lol
-1
u/Available_Safe1818 1d ago
No, you asked if it was good or ok. It's like you want us to rate how good of a job you did making 2 pieces of toast. Is it good toast, or is it just ok?
3
u/ceej13_ 1d ago
Brother brother i wanted to know if its good for the time I have been coding i never asked if I am really good and should get into harvard
2
u/Available_Safe1818 22h ago
For 4 hours, anything that runs and looks like it does what you want is fine.
It's hard to say because it's Python and you didnt format the indentation correctly here.
1
1
u/paperic 1d ago
print("perfect choice especially for a man")
how do you know it's a man?
Not bad for 4 hours in.
Just out of curiosity, any AI involvement?
while again not in ['yes', 'no']:
Using array literals like this is surely elegant, but it's not exactly something that beginners tend to figure out on their own.
•
u/desrtfx 1d ago
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: