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
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.
+ 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")
+ 3
print(f"{i}\n{i}")
+ 1
Woe It works thanks 😉 Denise
0
I want the output to look like this
1
1
2
2
3
3
4
4
5
5
6
6
7
7