string = " "
for x in range(1,10):
print("x is ", x)
string += "" + str(x)
print("Now, x is ", x)
print("All previous numbers: ", string)
Die hier muss ich zur while schleife umwandeln.. kann mir bitte jemand dabei helfen

Danke im vorraus.
rejes
Code: Alles auswählen
string = ''
iterator = iter(range(1, 10))
while True:
try:
x = next(iterator)
except StopIteration:
break
else:
print('x is', x)
string += str(x)
print('Now, x is', x)
print('All previous numbers:', string)