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”.
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? '))
Comments
Leave a comment