Monday, 15 April 2013

python - Zodiac program, with Comparing int.input to variables with incrementle Ranges -



python - Zodiac program, with Comparing int.input to variables with incrementle Ranges -

so i'm trying write programme in python asks user input birthday in dd/mm/yyyy format , have them confirm birthday comparing mm entered list of 12 months , display "so born on (month=mm), (dd), of (year=yyyy). i'm not quite sure how compare int.input (month,month,month)=range 1-13 import variable month print string.

but major issue comparing input year extensive range of possibilities

rat range (1901, 2020, 12) ox range (1902, 2020, 12) tiger range (1903, 2020, 12) rabbit range (1904, 2020, 12) dragon range (1905, 2020, 12) snake range (1906, 2020, 12) horse range (1907, 2020, 12) goat range (1908, 2020, 12) monkey range (1909, 2020, 12) rooster range (1910, 2020, 12) dog range (1911, 2020, 12) pig range (1912, 2020, 12)

i know set each date on own that's @ to the lowest degree 100 different variables or if statements. there way either set numeric variable has increments, such a = 1901 + 12 (continued) if year = 1901 or number in series such 1913 or 1937, or way set ranged variable can equated int user input?

you inquire user birthday answer = raw_input(), check if conversion date valid using seek , except:

from datetime import datetime while true: print 'input date (dd/mm/yyyy)' reply = raw_input() try: date = datetime.strptime(answer, '%d/%m/%y') print 'so born in {}'.format(date.month) break except: pass

python variables range

No comments:

Post a Comment