Nov-20-2020, 03:10 PM
(Nov-20-2020, 02:55 PM)perfringo Wrote: You should try it with 'no' and it will print twice. Why? You iterate over answer characterwise:
for reservation_reply in reservation_prompt: # i.e.: for char in reservation_prompt:As no character match 'yes' else suite is executed by number of iterations over user input.
Can be illustrated as:
>>> reservation_prompt = 'yes' >>> for reservation_reply in reservation_prompt: ... print(reservation_reply) ... y e s
Thank you very much for your reply! Honestly I really appreciate this.
So what you are saying is, the reason the return prints 3 times for "yes" is because of the characters?
And "no" prints out two times because of the characters.
How can I get one return for "yes" and for the "else" the return for "no"
Basically a return of one line... not multiple..
Many thanks!