'Why do I keep on getting the error "name 'amazon_soup' is not defined"
Solution 1:[1]
Since you have the amazon_soup used as an argument to the method and you use it as a variable which is undefined.
It should be:
print(getnextpage(geturl(amazon_url)))
The amazon_soup variable you have declared is local to the method geturl.
Solution 2:[2]
The variable "amazon_soup" is not defined in the current context. In python, and in many other languages, the "level", in which you define a variable matters. This means that you cannot access it from outside of the "level" you are in. In your case, the variable is defined in a function and thus it cannot be access outside of this function. Change the code in line 4 to define amazon_soup at the start, the same way you did for amazon_url. So just add
amazon_soup = None
at the start of line 4. Then run line 4 and line 5.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Opal |
| Solution 2 | Opal |

