Why this code doesn't function? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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

11th Jan 2021, 2:25 PM
Simone
Simone - avatar
4 Answers
+ 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))
11th Jan 2021, 2:27 PM
Steven Wen
Steven Wen - avatar
0
Ok i test
11th Jan 2021, 2:27 PM
Simone
Simone - avatar
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.
11th Jan 2021, 2:29 PM
Zohaib 👑
Zohaib 👑 - avatar
0
ok thanks
11th Jan 2021, 6:08 PM
Simone
Simone - avatar