Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Python Basics Functions and Looping While Loops

I didnt get that how the program understands that the object attempt_count is actually the number of attempts

I didnt get that how the program understands that the object 'attempt_count' is actually the number of attempts.I gave the object another name 'count' and it still worked.

3 Answers

Podrig Leoghain
Podrig Leoghain
5,094 Points

attempt_count isn't the name of a previously defined function. It is the name of the variable which you specify in this code as starting at 1, and increasing by 1 (attempt_count += 1) every time the while loops (password invalid).

basically the repl doesn't recognize the keyword to mean the attempt count, but rather it uses the counter you designed to count up to three

The name of the variable doesn't matter. It just has to be a valid variable name.

Let me know if this helps here