single range function - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html) +--- Thread: single range function (/thread-30101.html) |
single range function - AgileAVS - Oct-05-2020 Hey I need help to create multiple loops in a single statement as: '''for n1,n2,n3 in range(1,501): ........code''' **TypeError: cannot unpack non-iterable int object** RE: single range function - ndc85430 - Oct-05-2020 What exactly do you mean? What would you expect that code to do if it were possible to write it? Also, why do you need to do something like this? Please give details so people can help you find appropriate solutions. RE: single range function - AgileAVS - Oct-05-2020 (Oct-05-2020, 08:04 AM)ndc85430 Wrote: What exactly do you mean? What would you expect that code to do if it were possible to write it? Also, why do you need to do something like this? Please give details so people can help you find appropriate solutions.I need the code to extract data from the web, however the problem is related to creating a single range statement. for n1, n2 , n3, n4, n5 in range(1,501): buyer=browser.find_element_by_xpath('/html/body/form/div[4]/div[5]/div/div[4]/table/tbody/tr['f'{n1}'']/td[4]/a') buyer=buyer.text seller=browser.find_element_by_xpath('/html/body/form/div[4]/div[5]/div/div[4]/table/tbody/tr['f'{n2}'']/td[5]/a') seller=seller.textand so on RE: single range function - buran - Oct-05-2020 range will yield one number at a time (i.e. per each iteration). That said it's still not clear what you want to achieve. Is it correct to assume you actually want to get 1, 2, 3, 4, 5 then 6, 7, 8, 9, 10 and so on? |