+ 1

Pls if am to do a while loop eg

x=1 While x<=10: Print (x) x=x+1 It would likely print 1 2 3 4 5 6 7 8 9 10 If i want it to be 12345678910 How do I do it pls And pls can anyone help with how I can use for loop for this

4th Sep 2022, 10:32 PM
Oyedeji Hiqmat
Oyedeji Hiqmat - avatar
8 Antworten
+ 6
print(x, end='')
4th Sep 2022, 10:33 PM
Slick
Slick - avatar
+ 3
Hi! While and Print must be in small letters.
4th Sep 2022, 10:49 PM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
+ 3
x=1 while x<=10: print(x, end="") x=x+1
5th Sep 2022, 1:46 AM
Sreeju
Sreeju - avatar
+ 3
for i in range(1,11): print(i, end=" ") Or: print(*[i for i in range(1,11)]) Or: print(*list(range(1,11)))
5th Sep 2022, 6:48 AM
Solo
Solo - avatar
+ 3
Print (x, end= ' ') Or if u want a space in between every number just give a space or tab like this print(x,end='\t') or print (x , end = ' ')
6th Sep 2022, 5:54 PM
KARAN SINGH D
KARAN SINGH D - avatar
+ 2
An easy way, look: result = "" x = 1 while x <= 10: result += x x += 1
5th Sep 2022, 11:02 AM
Ramtin Jafari
Ramtin Jafari - avatar
+ 2
I forgot, type print(result) in the end
5th Sep 2022, 11:06 AM
Ramtin Jafari
Ramtin Jafari - avatar
+ 1
x += 1 is equal to x = x + 1
5th Sep 2022, 11:04 AM
Ramtin Jafari
Ramtin Jafari - avatar