0

unbound local error

I wrote the code which prompts the user to guess a secret letter between a and g, but i keep getting unbound local error after the last attempt (user has 3 guesses) 1. why is the error occuring 2.what is the best way to debugg it 3. can someone please explain unbound local error. googled it but cant find satisfactory answers. https://code.sololearn.com/c0G4XnL4f0Ho/?ref=app

11th May 2018, 5:53 PM
Doe Dare Oladimeji
Doe Dare Oladimeji - avatar
1 ответ
+ 9
You need do initialize val before the loop. Best would be with the initial value of "Incorrect" or something. Let's say in the line 4. Otherwise, you refer to a variable (val) before it is initialized. So you tell Python to return a value equal to a variable which was not yet assigned to anything.
11th May 2018, 7:01 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar