Hi guys,
I’m new here and am stuck on Lists and For Loops.
I’ve reached the stage where i am to create a list using syntax shortcut.
I have input code
‘’’ row_1[2:5] ‘’’
which works fine when i run the code, however when i try to save it as a variable using code
‘’’ print (last_3_fb) ‘’’
I am receiving an error message saying
NameError: name ‘last_3_fb’ is not defined.
Any help would be much appreciated.
Thankyou
Rucha
#2
hey @h.shields
print()
would print the result/ variable. where is the code where-in you are actually trying to store the the value?
my best guess you need to add the new variable like below:
print(row_1[2:5])
last_3_fb = row_1[2:5]
print(last_3_fb)
this would assign the result of row_1[2:5]
to the variable last_3_fb
("=" will assign).
Hi Rucha,
Yes that was indeed the one step I was missing.
Many thanks