Hello, I'm writing a short program in Python 3.8 (Pycharm) with the following target: welcomes users in a party as they check in.
The steps are the following:
1- Ask the user how many guests are in the group.
2- Using a loop which runs based upon how many guests were input above, ask users for their name.
3- Print out for each user “Hello {name}, you are person {number} to check in today”
Example input:
2
Tom
George
Output:
Hello Tom, you are person 1 to check in today
Hello George, you are person 2 to check in today
I wrote the following:
Can anybody help with this issue?
Thanks,
Paul
The steps are the following:
1- Ask the user how many guests are in the group.
2- Using a loop which runs based upon how many guests were input above, ask users for their name.
3- Print out for each user “Hello {name}, you are person {number} to check in today”
Example input:
2
Tom
George
Output:
Hello Tom, you are person 1 to check in today
Hello George, you are person 2 to check in today
I wrote the following:
# Step1: acquisition of the number of guests in the group print("Please type how many guests are in your group:") inputnum1=int(input()) print(type(inputnum1)) print(" ") # Step2: loop for collecting the names of the guests start=0 end=inputnum1 step=1 for idx in range(start,end,step): print("Please write your name here:") inputnames=input() print(inputnames) print(" ") # Step3: loop for the welcoming message of each guest: Hello {name}, you are person {number} to check in today names=inputnames id_guest=0 start=0 end=inputnum1 step=1 for idx in range(start,end,step): id_guest+=1 idguest=str(id_guest) print(f"Hello "+names[idx]+", you are person "+idguest+" to check in today")[/color]The problem with the above is that while the number (idguest) is incrementing, the names don't.
Can anybody help with this issue?
Thanks,
Paul
buran write Oct-11-2021, 08:51 AM:
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.