2 Antworten
+ 6
This seems like a set as the items are placed in curly braces, and the code is supposed to output the third item(2nd index) from App.
App = {"solo", "learn", "killer", "bean"}
print(App[2])
But this would raise a TypeError because sets are unordered and you can't access its items by index. If you meant to use an ordered collection, you likely meant using list(items in square brackets):
App = ["solo", "learn", "killer", "bean"]
print(App[2]) #outputs killer
+ 6
Chima Akachukwu another way to look at this is sets are "Unordered" while lists and tuples are Ordered / indexed...
Imagine having a bag of marbles and not a linear tray so each time you reach in the bag you never know which marble you are going to grab first, second, third, fourth, and so on.
https://sololearn.com/compiler-playground/c3gPDv24ARHh/?ref=app