+ 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
8 odpowiedzi
+ 6
print(x, end='')
+ 3
Hi! While and Print must be in small letters.
+ 3
x=1
while x<=10:
print(x, end="")
x=x+1
+ 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)))
+ 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 = ' ')
+ 2
An easy way, look:
result = ""
x = 1
while x <= 10:
result += x
x += 1
+ 2
I forgot, type print(result) in the end
+ 1
x += 1 is equal to x = x + 1