It is for dictionary, This is the challenge i was given.
Here is the complete code. I am now running into issues with the original dictionary being out of scope and then new problems when I try to use global.
Complete code as it stands
File "C:/Users/c0unt3rpl4y/PycharmProjects/House/scratchpad.py", line 26, in <module>
test()
File "C:/Users/c0unt3rpl4y/PycharmProjects/House/scratchpad.py", line 23, in test
return a[::2]
TypeError: 'int' object is not subscriptable
I am really new to this so I keep googling various ideas and then taking snippets of code and throwing them in and trying to make them work.
I will try it your way now and see if that works better
Your code snipped
Here is the complete code. I am now running into issues with the original dictionary being out of scope and then new problems when I try to use global.
Complete code as it stands
mport string letlist = list(string.ascii_lowercase) #Create string of letters letstring = string.ascii_lowercase #Create list of numbers list1=[] for i in range (1, 27): list1.append(i) #Create dictionary for part 1 def dictfunc(): global zipped zipped = dict(zip(list1,letlist)) dictfunc() def test (): for a in zipped: return a[::2] print (a)Errors:
File "C:/Users/c0unt3rpl4y/PycharmProjects/House/scratchpad.py", line 26, in <module>
test()
File "C:/Users/c0unt3rpl4y/PycharmProjects/House/scratchpad.py", line 23, in test
return a[::2]
TypeError: 'int' object is not subscriptable
I am really new to this so I keep googling various ideas and then taking snippets of code and throwing them in and trying to make them work.
I will try it your way now and see if that works better
Your code snipped
for num in zipped: if num % 2: print(num)Does indeed return the odds numbers but it does not return every other value of the dictionary which is the final piece of it. I think I need to maybe use index?