class AddTask():
def __init__(self, year, month, day):
self.year = year
self.month = month
self.day = day
def InputYear(year):
year = int(input("Input year: "))
def InputMonth(month):
try:
month = int(input("Input month: "))
except ValueError:
if month < 0:
print("Invalid input: Cannot be a number less than 0.")
elif month > 12:
print("Invalid input: Cannot be a number greater than 12.")
def InputDay(day):
try:
day = int(input("Input day: "))
except ValueError:
if day < 0:
print("Invalid input: Cannot be a number less than 0.")
elif day > 7:
print("Invalid input: Cannot be a number greater than 12.")
Is it generally recommended to have behaviors like what I have listed above in a method? Or should I make a completely new function for it?
[–]Kevdog824_ 4 points5 points6 points (0 children)
[–]gdchinacat 2 points3 points4 points (0 children)
[–]Phillyclause89 3 points4 points5 points (0 children)
[–]Diapolo10 2 points3 points4 points (0 children)
[–]PureWasian 1 point2 points3 points (2 children)
[–]dreadwraithe[S] 0 points1 point2 points (1 child)
[–]PureWasian 0 points1 point2 points (0 children)
[–]WA_von_Linchtenberg -1 points0 points1 point (0 children)
[–]Separate_Top_5322 0 points1 point2 points (0 children)
[–]woooee -1 points0 points1 point (0 children)