0

doubling a number on a new line

l am trying to write a code that will output numbers doubling twice but on a new line. Like in this way. 1 1 2 2 3 3 4 4 5 5 6 6 7 7 antill 40 40 This is what I have so far Anyone to help? i = 1 while 1==1: print(i) i = i + 1 if i >= 41: print("Breaking") break print("Finished") https://code.sololearn.com/c6V55ko4rxQn/?ref=app

8th Mar 2021, 3:32 PM
Steve Nova
Steve Nova - avatar
5 ответов
+ 5
Hello Steve Nawa Why not just print i twice? print(i) print(i) By the way: I would not use a condition like 1==1 while i <= 40 should do the job.
8th Mar 2021, 3:40 PM
Denise Roßberg
Denise Roßberg - avatar
+ 3
Steve Nawa If you just print i twice it works: i = 1 while i <= 40: print(i) print(i) i = i + 1 print("Finished")
8th Mar 2021, 3:43 PM
Denise Roßberg
Denise Roßberg - avatar
+ 3
print(f"{i}\n{i}")
8th Mar 2021, 3:49 PM
Oma Falk
Oma Falk - avatar
+ 1
Woe It works thanks 😉 Denise
8th Mar 2021, 3:49 PM
Steve Nova
Steve Nova - avatar
0
I want the output to look like this 1 1 2 2 3 3 4 4 5 5 6 6 7 7
8th Mar 2021, 3:39 PM
Steve Nova
Steve Nova - avatar