How to print the powers of 2 in Python? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to print the powers of 2 in Python?

How to print the powers of 2**x where x=x+1 and it carries on forever? Thanks

12th Mar 2020, 8:31 AM
Lucas Lee
Lucas Lee - avatar
3 Answers
+ 1
Lollipop Just do like this x = int(input()) while x > 0: print(2**x) x = x + 1
12th Mar 2020, 8:39 AM
A͢J
A͢J - avatar
+ 1
Wow thanks 😊
12th Mar 2020, 10:48 AM
Lucas Lee
Lucas Lee - avatar
0
What? Can you explain a bit more?
12th Mar 2020, 8:34 AM
Utkarsh Sharma
Utkarsh Sharma - avatar