Python Forum
Printing output without print usage
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Printing output without print usage
#1
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='.')
Reply
#2
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Python VS Code: using print command twice but not getting output from terminal kdx264 4 1,035 Jan-16-2023, 07:38 PM
Last Post: Skaperen
  How to output one value per request of the CSV and print it in another func? Student44 3 1,278 Nov-11-2022, 10:45 PM
Last Post: snippsat
  How to print the output of a defined function bshoushtarian 4 1,237 Sep-08-2022, 01:44 PM
Last Post: deanhystad
Sad Want to Save Print output in csv file Rasedul 5 10,688 Jan-11-2022, 07:04 PM
Last Post: snippsat
Photo print output none 3lnyn0 4 1,756 Nov-01-2021, 08:46 PM
Last Post: 3lnyn0
  output correction using print() function afefDXCTN 3 10,965 Sep-18-2021, 06:57 PM
Last Post: Sky_Mx
  print (output) taaperaban 3 1,882 Sep-03-2021, 04:23 PM
Last Post: deanhystad
  print not printing newlines rocket777 4 2,256 Jul-03-2021, 09:43 PM
Last Post: bowlofred
  print function output wrong with strings. mposwal 5 3,046 Feb-12-2021, 09:04 AM
Last Post: DPaul
  Print output not working xninhox 7 3,942 Jan-16-2021, 09:42 AM
Last Post: xninhox

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020