I'm a beginner in python and I've recently learned how to do the basics of:
functions, loops, ranges, for/if statements, and string slicing.
So far I have:
date = raw_input("Enter the date checked out in YYYY-MM-DD format: ")
dueDate = raw_input("Book is due:")
length = len(date)
counter=0
for i in range(length):
if date[i] == "-":
counter = counter + 1
if 1 < counter < 2:
print date
if counter > 2:
print date,"too many hyphens"
if counter <= 1:
print date,"not enough hyphens"
Then I had:
year = date[0:4]
month = date[4:6]
day = date[6:10]
if year == date[0:4]:
year=year
if month == date[4:6]:
month = month
if day == date[6:10]:
day=day
print year+month+day
I'm trying to break it down into YYYY-MM-DD and then compute a due date 7 days from the date the user entered.
The second part of the program didn't work with the first, I don't know how to combine them, (or if that should be there at all) would I have to use a function?
Leap years do not need to be accounted for, and I can not use modules like datetime and time since I haven't learned them and I want to write all the code using different variations of loops and if/elif statements.
If someone can help point me to the right direction I would really appreciate it!
Thanks,
D