Problem with local variable
First off, here is the link: https://repl.it/@Deacon_Cronin/Final-Project-Hack
I'm working on this as a project. I'm a high school freshman right now, this is for my CS class. I'm having some trouble as when I call the random mission function normally it works fine and has no problems, but when I call it through the main menu function (check email and go to bar) it breaks. I have no idea why this is happening. Any help would be appreciated
Here is the repl I made from your code: https://repl.it/@heyitsmarcus/Final-Project-Hack
So, the problem you're running into is that when
difficulty
gets passed into yourguesser
function,difficulty
is not of typeint
.difficulty
is actually astring
. And the reason for this (took a minute to trace it back) is that when you are passing thedifficulty
asdif
to therandom_mission()
function, you are passing it directly frominput
which makes it of typestring
. But, you needdif
to be of typeint
to pass theif
andelif
conditions (and to apply any math to it).All you have to do to fix this problem is to pass it as an
int
to therandom_mission()
function by wrapping it in theint()
method.That was all that was needing to be done! Now, when you run it, you can start breaking passwords!
@heyitsmarcus Thank you very much!
@Deacon_Cronin You are most welcome! Happy Coding, Deacon!