Discover the answers you need at Westonci.ca, a dynamic Q&A platform where knowledge is shared freely by a community of experts. Explore comprehensive solutions to your questions from a wide range of professionals on our user-friendly platform. Get precise and detailed answers to your questions from a knowledgeable community of experts on our Q&A platform.

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

Sagot :

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.