On 24/11/2018 20:37, Brian Ngari wrote: > miles of that number. Please prompt the user for the current mileage > recorded on the car and also for the mileage recorded on the car at the > time of the last oil change. Then, please let the user know if it’s time to > change the oil.
You do some of this but you don't check if they need an oil change. > Be sure to check for invalid entries (e.g., if the mileage... > and, if there are invalid entries, please continue to prompt the user. And you don't do this. You need a loop somewhere... I suggest before worrying about the oil change code that you get the input bit working, just print the two values initially. Once you can correctly read two valid values move on to using them to check the oil. > input('Enter the number of miles') You don't store this value anywhere > x=int(input('Enter the last milage you went for an oil change.')) > > if x>5000: > print('You need an oil change.') This claims you need an oil change if the mileage at the last change was >5000. Even if I haven't driven any miles at all since then. Something wrong. You need to use both the values that you read from the user. > else: > x<5000 This doesn't make much sense. You compare x to 5000 but don't do anything with the result. I'm not even sure what you are trying to do here. > print('No oil change.') Remember indentation is all important in Python. Here you always print the message regar5dless of what happened further up. > I'm getting two different answers as outputs. I don't know why. Probably that last indentation issue to blame for that. More seriously you are not doing what the homework assignment asks you to do. Read it again and see my comments above. Have another go and if still stuck come back to us. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor