₦airaland Forum

Welcome, Guest: Register • Login • With Google • Trending • Recent • New

Stats: 3,344,134 members, 8,510,288 topics. Date: Friday, 30 October 2026 at 07:51 AM

Toggle theme

I need assistance with this Python Problem - Programming - Nairaland

Nairaland Forum › Science/Technology › Programming › I need assistance with this Python Problem (492 Views)

1 Reply (Go Down)

I need assistance with this Python Problem by Tarvel(op):
Good afternoon, I need assistance

For example

a = int(input())

while True:
Print ( a // 2)

The problem is how do I make variable a equal to the next answer, and then the next answer equal to the next?

Let's say a = 10
It'll print 5
How do I make it print (5 // 2)
And then print (2 // 2)...

I'm not sure if I explained it properly, but I need assistance. Thanks in advance
Re: I need assistance with this Python Problem by Tarvel(op): 1:48pm On Jan 07, 2021
Anybody?
Re: I need assistance with this Python Problem by Tarvel(op): 1:57pm On Jan 07, 2021
Tarvel:
Good afternoon, I need assistance

For example

a = int(input())

while True:
Print ( a // 2)

The problem is how do I make variable a equal to the next answer, and then the next answer equal to the next?

Let's say a = 10
It'll print 5
How do I make variable a equal 5 so that it'll automatically print (5 // 2)
And then print (2 // 2)...

I'm not sure if I explained it properly, but I need assistance. Thanks in advance
I've modified my question
Re: I need assistance with this Python Problem by Nobody: 2:10pm On Jan 07, 2021
You assign the answer to the same variable

a = int(input())

while a > 0 : #You don't want an infinite loop
a = a/2
print(a)

This is what I understood from the question
Re: I need assistance with this Python Problem by Tarvel(op): 2:34pm On Jan 07, 2021
This is what I'm trying to figure out

Re: I need assistance with this Python Problem by Tarvel(op): 2:34pm On Jan 07, 2021
DrLevi:
You assign the answer to the same variable

a = int(input())

while a > 0 : #You don't want an infinite loop
a = a/2
print(a)

This is what I understood from the question
Please check the picture above, thanks
Re: I need assistance with this Python Problem by Tarvel(op):
DrLevi:
You assign the answer to the same variable

a = int(input())

while a > 0 : #You don't want an infinite loop
a = a/2
print(a)

This is what I understood from the question
I want an infinity loop, I want it to continue giving me the output of a but with the consecutive answers till I get 1 as my answer
Re: I need assistance with this Python Problem by Tarvel(op): 3:10pm On Jan 07, 2021
I've gotten it now, thanks smiley sad

Re: I need assistance with this Python Problem by Deicide: 5:48pm On Jan 07, 2021
Remove that While b==True
1 Reply

Who Can Help Out With This Python Problem? • Help With This Python Programming Assignment Please • Can Someone Help Me With A Solution To This Python Problem • 2 • 3 • 4

Mobile Tracker • How Do Websitesite Or Software Identifies Visitors. • Do You Love Coding?