dimanche 20 août 2017

Python strings and if statements

I am having trouble with my Python code. The question that I am supposed to write a program for is below as well as my code. My code works fine in Wing IDE when I run it with different input values for steps, however when I submit it to the system which checks my code I get errors as shown below. Thanks in advance for any help. My code is below.

def activity_level_from_steps(steps):
"""Takes an amount of steps and returns the level of exercise it equals"""
steps = int(steps)
if steps < 1:
    level = 'alive?'
elif steps >= 1 and steps < 5000:
    level = 'sedentary'
elif steps >= 5000 and steps < 7500:
    level = 'very low'
elif steps >= 7500 and steps < 10000:
    level = 'low'
elif steps >= 10000 and steps < 12500:
    level = 'active'
else:
    level = 'very active'

    return level

The question I am required to solve The error that the system which checks my code gives me

Aucun commentaire:

Enregistrer un commentaire