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 trialjamie Macdiarmid
2,048 PointsStuck
!. Firstly could someone talk me through each stage of this line? guess = int(input("Guess a number between 1 and 10:"))
- Can I get a few clues for this code challenge ( even.py)
I think I try to overcomplicate things and then once your thinking in those terms various bits of code want to include themselves!1
Thanks
def even_odd(int(input(1,10))
if
1 Answer
Vittorio Somaschini
33,371 PointsHello Jamie.
Let's have a look at the line of code that is stressing you ;)
guess = int(input("Guess a number between 1 and 10:"))
Here you are creating a variable called guess and setting it to the integer value of the input that the user provides answering to "Guess a number between 1 and 10:".
So, you ask the user for a number between 1 and 10, then we add int() to make sure we get an integer stored in the guess variable.
Talking about the code challenge, you are doing ok, but the function is not supposed to take an input from the user (I believe), so as you wrote:
def even_odd(number):
Don't forget the ":" at the end of the line.
inside the function you are right, we want to have an if statement that check if the number argument we pass in is even and to do this we use the % (remainder). So if an even number is passed in the remainder of the division between that number and 2 (number % 0) will be 0. On the other hand (else) if the remainder is not 0, this means that the number passed it is odd.
Let me know if you are still struggling with this!
Vitto
jamie Macdiarmid
2,048 Pointsjamie Macdiarmid
2,048 PointsHey Vitto
Thanks for your help earlier but I'm still stuck on this one. I know once its in front of me I'll see it but not seeing it right now.
Thanks again