Question #345293

Ask the user to input a number and then ask if they want to double the number. If they answer “y”multiply the number by 2 and display the answer. Keep repeating this loop, doubling their number each time, until they no longer reply “y”.

Expert's answer

n = int(input('Input a number: '))
answer = str(input('Do you want to double it? '))
while answer == 'y':
    n=n*2
    print(n)
    answer = str(input('Do you want to double it? '))

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS