vendredi 26 février 2016

Using multiple input statements with if/else

I am trying to create a simple program based on what mode of transport people should take to work if it is raining depending on how far they live:

< 2km = "walk"
> 10km = "bus"
>= 2km and <=10km = "bike"

I have worked out the first bit (well at least I think I have), but I'm stuck as to how to integrate the different if statements for the different distances. So once a person answers "no" to the question "is it raining today", they then have to enter an integer number for how far they live from work and based on this it will tell them what mode of transport to take.

Any help would be greatly appreciated

`weather = input("Is it raining today? ")
if weather == "yes":
print("You should catch the bus to work.")
elif weather == "no":
input("How far in km do you need to travel? ")`    

Aucun commentaire:

Enregistrer un commentaire