I am teaching myself Python and following a YouTube tutorial I input the following:
Thank you
xs = [12, 14, 10] for num in xs: x += num print(x)This works in the tutorial and sums the list to 36, but on my Python I get the following error message:
Python 3.8.2 (tags/v3.8.2:7b3ab59, Feb 25 2020, 22:45:29) [MSC v.1916 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license()" for more information. >>> = RESTART: C:/Users/John/Documents/John''s files/Work/Coding/Think Like a Computer Scientist/Programmes/loop_exercise2a.py Traceback (most recent call last): File "C:/Users/John/Documents/John''s files/Work/Coding/Think Like a Computer Scientist/Programmes/loop_exercise2a.py", line 4, in <module> x += num NameError: name 'x' is not defined >>>I would appreciate any advice or help.
Thank you