Create your own for/else


#1



https://www.codecademy.com/courses/python-beginner-en-cxMGf/2/6?curriculum_id=4f89dab3d788890003000096


Traceback (most recent call last):
File "python", line 1, in
NameError: name 'ps4' is not defined


Not sure why it doesnt know what ps4 is. It is in a list, does it need to be defined?


https://gist.github.com/e7778f64b581a11acb4f66e4b790b2d1


#2

variables always need to be defined, are you sure you don't want to use strings for the different gaming consoles?


#3

am i not declaring that gamingsystems is a list containing ps4, ps3, ps2, xbox, tomato?


#4

yes, but ps4, ps3, ps2, xbox and tomato are undefined variable. Now read my answer again:


#5

got it!

thank you for not just giving me the answer. Made me really think and now i will remember it.


#6

that is my definition of help, you're welcome :slight_smile:


#7