Can you please help!

Hi!

Please, in the 2nd last line can you remind me what the spread.item() does?
Any info about it would be appreciated!
For example, where does the word spread come from? Is it just a random word that we make up?
in the () after items always left blank?

Lastly, why are there “+” symbols before and after the words key and value on the last line?

I am a beginner at this!

Thank you very much!

Josh

sounds like an excellent question for documentation? Have you tried googling something like: python dictionary items?

that is the name of the dictionary you create. Of course this name can be anything, but you want to give your variable logical names for readability

.items() is a method (if methods have not been cover, you can think of methods like a sort of function), if a method doesn’t require arguments, they are left blank

+ is used for string concatenation. Has string concatenation been taught yet?

1 Like

Even beyond google, you can ask python in the terminal help(dict) (print if you’re not in the terminal).

1 Like

Hi Stetim,

Thank you very much for your help!

A couple of quick follow ups:

  1. In spread[“past”] = tarot.pop(13)
    Why does it use the brackets? Spread seems to be a dictionary
    Also where do the “past”, “present” and “future” come from?
    lastly this “pop” method seems different from the one that I learned:
    https://www.w3schools.com/python/ref_list_pop.asp

  2. regarding the last question; I thought that to concatenate you just put the + before. I didn’t realize that it was written like +key+ with the + immediately touching on both sides.

Please any advice?
Thank you very much!

Respectfully,
Josh

that is list pop, this is dictionary pop

they are the names you give your key.

to assign a new (or update) an element in a dictionary we do:

dict[key] = "new value"

if the variable is at the end of your sentence:

print("some example " + var)

then not. But if the variable is in the middle of the string, then you need to concatenate everything together.

2 Likes