0
Why this code doesn't function?
I create this code but it doesn't function import random r = ("1","2","3","4","5","6","7","8","9","10","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z") c = 0 if c < 10: while True: c + 1 print(random.choice(r)) else c - 10 https://code.sololearn.com/cy50q8fGcb3L/?ref=app
5 ответов
+ 4
Try changing the r = (...) to r = [...] and also change your while True because the loop never ends
Here, i fix your code for you:
import random
r = ["1","2","3","4","5","6","7","8","9","10","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
c = 0
while c < 10:
c += 1
print(random.choice(r))
0
Ok i test
0
import random
r = ("1","2","3","4","5","6","7","8","9","10","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z")
c = 0
if c < 10:
while True:
c = c + 1
print(random.choice(r))
else:
c -= 10
Try this, your code never stop because while is True.
0
ok thanks