Variable not defined when the variable is spelt correctly

Problem description:
So in python, I was trying to bug fix my project when I found a bug in which even if you created and spelt the variable correctly, it still outputs an error. I used a variable name as an input Just to know, The variable used to work correctly.

Expected behavior:
The string variable to work correctly

Actual behavior:
Outputs an unfixable error in which it means the variable was not defined

Steps to reproduce:
Make a str variable, use the variable correctly with the variable name spelt correctly, make a str variable with random text, put it into the other str variable. It happens to all the other variables also.

Bug appears at this link:
https://replit.com/@RichardSchiel1/Python-Quiz-Game#main.py at line 218

Browser/OS/Device:
Windows 11 Home, Chrome Browser

This is happening because you chose 1 question so customquestion2 and question2answer were never defined.

Not sure how you would fix it though.

Also, input() returns a string by default, so you don’t need to use the str() function around it.

1 Like

Sorry, but this might be outdated. Thanks for your help though.

1 Like

Suprizingly, I have fixed it.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.