Python Forum

Full Version: Printing output without print usage
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello Everyone,

I am new to programming and new to python. I tried to run below program and it gave me the first value i entered. After first value if I press enter it gave me second value and so on and it didn't exit the program. Please help me out with errors.

userdata = [
            "Enter your first name: ",
            "Enter your middle name: ",
            "Enter your last name: ",
            "Enter your age: ",
            "Enter your mobile number: ",
            "Enter your street name: ",
            "Enter your city name: ",
            "Enter your state name: ",
            "Enter your postal code: ",
            "Enter your country name: "
            ]
counter = 0
for i in userdata:
    if userdata[counter] == 3 or userdata[counter] == 4:
        userdata.append(int(input(i)))
    else:
        userdata.append(input(i))
    counter += 1
if userdata[3] < 20:
    print('According to your age, You are young')
else:
    print('According to your age, You are not young')
print("Hello", userdata[0],userdata[1],userdata[2], "You are",userdata[3], "years old.", "After 10 years your age will be", userdata[3]+10,"years old.")
print("Your mobile number is", userdata[4],sep=': ')
print("You live in:",userdata[5],userdata[6],userdata[7],userdata[8],userdata[9],end='.')
Try using two lists. One list like you have with all of the questions, and a second list with all of the answers.
You are tacking the answers onto the end of your list so the indices are not lined up.