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

Help with this code

1 limport math

3def ypc(yards, carries): 4return math(yards / carries) 5try: 6 yards = int(input("yards gained? ")) 7 carries = int(input("rushing attempts? ")) 8except ValueError: 10 print("invalid value") 9else: 11 average = ypc(yards, carries) 12 print("yards per carry {}".format(average))

I get this error import math

def ypc(yards, carries): return math(yards / carries) try: yards = int(input("yards gained? ")) carries = int(input("rushing attempts? ")) except ValueError: print("invalid value") else: average = ypc(yards, carries) print("yards per carry {}".format(average)) note I put in the line numbers on the question because the formatting gets messed up with copy and paste.

boi
boi
14,242 Points

Use proper code formatting, to help better understand your problem. Learn it here.

1 Answer

Your code says "limport math." It should be import math.