im an absolute beginner, would really appreciate an explanation of my mistake.
My loop looks like this:
if c_or_nc==('Yes'):
continue_=True
if c_or_nc==('No'):
continue_=False
while continue_ is True:
n1 = float(input('Please, enter a number: '))
op=input('Enter an operator (+, -, *, /, ^): ')
n2=float(input('Enter a second number: '))
print('The result is: '+str(result))
c_or_nc=input('Do you want to continue? (Yes/No): ')
while continue_ is False:
print('Alright! Have a nice day :).')
The output is what i want it to be if the answer is ‘No’ the first time and loop doesnt start. After that whatever the answer is, loop continues.
I think i know why that is? Is it because if the answer is ‘Yes’ the first time continue_ becomes True period? Ive tried, but dont know how to fix that.
Thanks!.
New contributor
Lyo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.