9.9k views
20 votes
Write a while loop that prints userNum divided by 2 (integer division) until reaching 1. Follow each number by a space. Example output for userNum

User Will Glass
by
7.6k points

1 Answer

6 votes

userNum = int(input("Enter a number: "))

while userNum > 1:

print(userNum, end=" ")

userNum /= 2

I wrote my code in python 3.8. I think this is what you want but I'm not too sure. I'll change the code if you need me to.

User Pierre Clocher
by
8.9k points