0

Pyhton quiz:- IT show me error at line 17 for i in range(0, urls):

import datetime url = 'www.google.co.in/chkin=2022-09-01&chkout=2022-12-01?q' days = 7 checkin = datetime.date.today() urls = [] for i in range(0, days): chkin = str(checkin + datetime.timedelta(days=i+1)) chkout = str(checkin + datetime.timedelta(days=i+2)) ind_chkin = url.find('checkin') + len('chkin=') ind_chkout = url.find('chkout') + len('chkout=') urls.append(url[:ind_chkin] + chkin + url[ind_chkin + len(chkin): ind_chkout] + chkout + url[ind_chkin + len(chkout):]) for i in range(0, urls): print(i)

17th Sep 2022, 5:54 AM
Deepanshu Bargal
Deepanshu Bargal - avatar
2 Réponses
+ 1
# Hi! I’m not really shure what kind of solution you want, but at least you can start with a running code: import datetime url = 'www.google.co.in/chkin=2022-09-01&chkout=2022-12-01?q' days = 7 checkin = datetime.date.today() urls = [] for i in range(days): chkin = str(checkin + datetime.timedelta(days=i+1)) chkout = str(checkin + datetime.timedelta(days=i+2)) ind_chkin = url.find('checkin') + len('chkin=') ind_chkout = url.find('chkout') + len('chkout=') urls.append(url[:ind_chkin] + chkin + url[ind_chkin + len(chkin): ind_chkout] + chkout + url[ind_chkin + len(chkout):]) for i in urls: print(i)
17th Sep 2022, 6:59 AM
Per Bratthammar
Per Bratthammar - avatar
+ 1
Per Bratthammar Thankyou very much, i finally available to solve the problem because of you actually, I stuck at line 17 its show me range for 0 to 7 but i want all the links but now i got.
17th Sep 2022, 8:55 AM
Deepanshu Bargal
Deepanshu Bargal - avatar