Can you repair this program? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Can you repair this program?

This is a program I wrote test to learn from experience. But it has an error that I cannot understand Can you explain this error and how to fix it (Error code I will note in the program in the location where the error is encountered) Thank you Link: https://code.sololearn.com/cA16a05A10A1

10th Feb 2021, 5:14 AM
Nguyễn Quốc Hưng
Nguyễn Quốc Hưng - avatar
2 Answers
+ 2
🔹Try to add global x in decode function ______________ def decode(): global x # codes ... ______________ 🔹Another way is to pass an argument to function. ______________ def decode(x): # some codes ... ... # call function with argument. if y == 0: decode(x) ______________ Please update us if this is still wrong. Thanks. https://code.sololearn.com/cdpGe0WwIyAz/?ref=app
10th Feb 2021, 5:38 AM
noteve
noteve - avatar
+ 1
Value is not assigned to x.
10th Feb 2021, 5:39 AM
Sanjyot21
Sanjyot21 - avatar