how do I replicate this with a for loop?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Anzol8

if the user types 4

program shows:

1
12
123
1234

if the user types 9

program shows:

1
12
123
1234
12345
123456
1234567
12345678
123456789

it can’t be just just showing “123456789”, it needs to be a sequence exactly like the one I showed.

:bust_in_silhouette: Reply From: Gluon

You need something like this

var toprint : String
for i in 10:
	toprint = toprint + str(i)
	print(toprint)

it didn’t work, it only prints 123456789.

Anzol8 | 2022-11-27 22:47

No it doesnt it prints exactly what you wanted.

Gluon | 2022-11-27 23:04

yes it does, thanks, I was just putting the print outside of the for-loop, already fixed it.

Anzol8 | 2022-11-28 02:07