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)
2 ответов
+ 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)
+ 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.