Hello I am new to Python and am trying to figure out why my list overwrites the previous elements every time a new page is loaded and scraped during the while loop. Thank you in
Because you reset urls to an empty list in every iteration of the loop. You should move that to before the loop.
urls
(Note, the whole thing would be better expressed as a for loop.)