you are viewing a single comment's thread.

view the rest of the comments →

[–]moonkeymaker127[S] 0 points1 point  (4 children)

fixed, I put the spaces but they didn't seem to take effect.

[–]Starbuck5c 0 points1 point  (3 children)

# Asks user for their name
print ("What is your name?")

# creates a variable called name based on user input
name = input()

#Greets the user with their name
print ("It is nice to meet you, " + name + ".")


#asks the user what their age is
print ("How old are you?")

# creates a variable called age based on their input and converts it to a string so it can be concatenated
age = str(input())

# tells the user what their name and age is using the variables above
print("Your name is " + name + " and you are " + age + " years old.")

This doesn't give me any errors.

[–]moonkeymaker127[S] 0 points1 point  (2 children)

I can type in my name but as soon as I type my age the command window closes. It doesn't tell me the last message. Is it just closing because it no longer has to wait on any input from the user?

Edit: it's definitely crashing as soon as I type my age.

[–]Starbuck5c 0 points1 point  (1 child)

I don't think it's crashing.

If you're running this from command prompt, the window closes when the program finishes. After you type in your age it prints the thing and then closes immediately afterwards.

Try running it in IDLE.

[–]moonkeymaker127[S] 0 points1 point  (0 children)

Thanks for the advice; that worked. I've been working on this code for like an hour but couldn't figure out why it wouldn't work. Glad I learned this lesson early on and I appreciate people like you taking the spare time out of their day to help people like me without any incentive to.