'Having trouble defining variable, Python 3.9, Spyder IDE [closed]
longitude[:] = lon
Code analysis says longitude variable not defined.
Solution 1:[1]
Use:
longitude = lon
but make sure lon has been defined first.
longitude[:] can only be used when longitude is previously assigned. Even then it is not a great way to define or reassign variables.
If you are trying to copy lon to longitude here is an example:
lon = [1,2,3]
longitude = lon[:]
print(lon)
Output:
[1, 2, 3]
Here you can use [:] to ensure you create an entirely new list. Maybe this is where the confusion came from.
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 | Eli Harold |
