Howfixthis¿ RU | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Howfixthis¿ RU

Хей ребят! Я должен был сделать что-то типо накопительной системы, за каждый правильный ответ даётся 15$ Т.е должно выходить 30,45, и тд но почему-то оно плюсуется только 1 раз, тобиш 30. Вы не могли бы мне помочь с этим? bbb=15 while True: c=(random.randint(1,20)) d=(random.randint(20,40)) e=str(c+d) print(c,"+",d,'= ?') g=(input("-> Ответ: ")) if(g==e): bbbb=bbb+bbb Всё в цикле.

7th Jan 2018, 8:59 PM
Non
Non - avatar
2 Answers
+ 3
Assuming you put the correct import statement for module 'random'), line: bbbb=bbb+bbb You use undefined 'bbbb' variable (4 'b') and assign it with 'bbb' (15) times 2, at each iteration of the infinite loop... (where you don't have a base case to exit neither handle an output of the result ^^)
7th Jan 2018, 11:35 PM
visph
visph - avatar
+ 1
I'm very glad that SoloLearn has such an amazing community :3 Thank you very much, I came up with a slightly different design, using the list and append. ThX!
8th Jan 2018, 12:10 AM
Non
Non - avatar