0

I am a beginner python programmer and am trying to figure out how to modify input from a user.

y=raw_input("Enter the date in this format 'yyyy-mm-dd'") #user enters 
x=y-2 #I know this isn't how you would do this just trying to show an example of 
#what I am attempting. 

I am trying to set a second variable x equal whatever date the user enters minus 2 days. I am later trying to pass the second variable in a datetime format in apscheduler. Is there any way to do modify a string like this?

Jack Gruber
  • 47
  • 1
  • 7
  • 2
    Many ways of doing it. 1. try reading up on https://docs.python.org/3.5/library/datetime.html . 2. If you don't want to use date time, you could just split the user input based on `-` and modify the correct slot of your new list and rebuild the string. – MooingRawr Sep 20 '16 at 15:11
  • Duplicate of a number of posts, Start from here http://stackoverflow.com/questions/466345/converting-string-into-datetime and end here http://stackoverflow.com/questions/6871016/adding-5-days-to-a-date-in-python – Bhargav Rao Sep 20 '16 at 15:12
  • Thanks guys I appreciate it! – Jack Gruber Sep 20 '16 at 15:28

0 Answers0