Python Forum
python age calculator need to find the number of years before they turn 100 not using
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
python age calculator need to find the number of years before they turn 100 not using
#4
(Mar-25-2018, 09:53 AM)orangevalley Wrote: so its:
elif: for age in range (o> -100:)
      print("Try again after you are born!.")

Did you try running it? You typed the letter 'o' for the number '0'. Why are you using 'range' at all? Why not just use 'age <= 0' as you did when testing for an input over 100.

In your 'else:' statement, if all works correctly, 'age' will always be between 1 and 99, subtracting 100 from 'age' will always make 'x' a negative number.

Finally, in your 'else' statement, the print function will cause an error. Can you see what the problem is?
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
Reply


Messages In This Thread
RE: python age calculator need to find the number of years before they turn 100 not using - by sparkz_alot - Mar-25-2018, 02:20 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Trying to find the next prime number FirstBornAlbratross 8 4,385 Aug-14-2023, 01:16 PM
Last Post: deanhystad
  Calculate AGE in years Kessie1971 17 3,566 Apr-26-2023, 03:36 PM
Last Post: deanhystad
  Python Program to Find the Factorial of a Number elisahill 2 1,445 Nov-21-2022, 02:25 PM
Last Post: DeaD_EyE
  Tracking leap.py years for gregorian calendar (Exercism org) Drone4four 11 3,841 Oct-14-2022, 03:20 PM
Last Post: betinajessen
  Python calculator help but not using while loop with true, any flags variable ,break kirt6405 13 5,798 Jun-08-2021, 06:39 AM
Last Post: Larz60+
  Calculator: several options, changing the number gus17 4 3,280 Dec-28-2019, 11:22 PM
Last Post: ichabod801
  How to find the accuracy vs number of neighbours for KNN vokoyo 3 3,188 Apr-10-2019, 03:46 AM
Last Post: scidam
  Problem with code to calculate weekday for leap years! Event 2 2,870 Dec-15-2018, 05:13 PM
Last Post: Event
  i need help in fixing my scientific calculator coding : (, im using python 3.5.5 hans77 1 4,185 Oct-17-2018, 03:26 AM
Last Post: stullis
  how to find a next prime number? iamyourfather 2 6,533 Oct-01-2017, 04:21 PM
Last Post: gruntfutuk

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020