Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- print("-------------------------------RESTART---------------------------------")
- day = int(input("Δώσε τον αριθμό που αντιστοιχεί στην ημέρα της ημερομηνίας: "))
- day = int(day)
- month = input("Δώσε τον αριθμό που αντιστοιχεί στο μήνα της ημερομηνίας: ")
- month = int(month)
- year = input("Δώσε τον αριθμό που αντιστοιχεί στο έτος της ημερομηνίας: ")
- year = int(year)
- isLeapYear = (year % 400 == 0) or (year % 100 != 0 and year % 4 == 0)
- validDaysPerMonth = [0, 31, 28, 31, 30 ,31 ,30 ,31, 31, 30, 31, 30, 31] # To 0 einai padding, gia na antistixei to index ston mina
- if isLeapYear:
- validDaysPerMonth[2] = 29
- if month<0 or month>12 or day<0 or day>validDaysPerMonth[month]:
- print("Δεν υπάρχει μέρα που να αντιστοιχεί στον αριθμό" + " " + str(day) + " " + "του μήνα " + " " + str(month) + " " + "για τον χρόνο" + " " + str(year))
- else :
- print("Η ημερομηνία " + str(day) + "/" + str(month) + "/" + str(year) + " " + "είναι έγκυρη")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement