Looking to switch careers and I’m learning Python for the first time with Codecademy. So far I’ve been doing the Python 2 lessons and I’m stuck on the Loops exercise 8/19.
The exercise consists of asking the player to guess a random number and if they do not guess correctly in 3 tries, they lose. I have gotten the win/lose part down (I think) but my code keeps giving the player 4 tries instead of 3. What am I doing wrong?
This is my code:
Your code looks good so far. You should get rid of that first
raw_input; and move that
guesses_left -=1 and it should work.
By the way, if you are looking to switch careers and learn Python; you should abandoned
Python2 and start learning
Python3. According to Python.org, Python2 was retired January 1, 2020, and they recommend upgrading to Python3. Do as you wish of course; this is only friendly advice to weigh your options.
Thank you for the advice! I started with Python 2 because Python 3 was a Pro course and I’m mainly looking to start with free courses first. I started with Python 2 because it was free and I have zero knowledge of coding so I just wanted to get a feel for what it was like. I will eventually move onto Python 3 after getting the basics down, I don’t expect the transition to be immensely difficult.