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
Arnav Goyal
1,634 PointsNeeded help in correcting this code.
def asking_your_name(): name = input("What's your name? ") print("Nice to meet you, {}.".format(name))
def asking_your_age(): age = input("What's your age? ") if age > 50: print("Time to leave your job. ") elif age > 30: print("Time to work!") elif age > 13: print("Wow! You are a teen!") else: print("Still a youngster! ") asking_your_name() asking_your_age()
this is my code. it is showing indentation error in line 8. i don't know how to rectify it. please help. thanks
4 Answers
Grigorij Schleifer
10,365 PointsHi Arnav,
this works fine for me:
def asking_your_name():
name = input("What's your name? ")
print("Nice to meet you, {}.".format(name))
def asking_your_age():
age = input("What's your age? ")
if age > 50:
print("Time to leave your job. ")
elif age > 30:
print("Time to work!")
elif age > 13:
print("Wow! You are a teen!")
else:
print("Still a youngster! ")
asking_your_name()
asking_your_age()
Hope this helps :)
Grigorij
Arnav Goyal
1,634 PointsNo I am not doing my homework. I am just learning python on my own. I just wanted build a simple program using waht I have learnt in python basics. That's all. Thanks by the way.
Grigorij Schleifer
10,365 PointsHey Armav,
how far did you get with the second task?
Arnav Goyal
1,634 PointsThanks. I just wanted to know how to attach your script as you have done the same.
Grigorij Schleifer
10,365 Points:)
Hey Arnav, what do you mean with "attach" your script?
You can use .format(play) method to format your lines of code. Is this what you need?
play = input("Want to play with you age? ")
print("Some text {}".format(play))
// instead of {} you will provide your input
Grigorij
Arnav Goyal
1,634 PointsAlso I needed a bit more help. I wanted to create an another variable name 'play' in asking_your_age function. play = input("Want to play with you age? ") This input should come along with the printed message in each of the four cases. Can you please code that for me.
Paul Ryan
4,584 PointsThis sounds like you are trying to get someone to do your homework.
How about you make an attempt and doing it and post up your work. We can then help point you in the right direction.