The 'in' Operator


#1

Help me please :cry:
Can't understand, why Error?

For each key in mydict: print out the key , then a space, then the value stored by that key._

(You should use print a, b rather than print a + " " + b.)

my_dict = {
    "Name":"Anton",
    "Age": 23,
    "Address": True
}

for key in my_dict:
    print(str(key) +  ' "" ' + str(my_dict[key]))

Oops, try again. It looks like you did not print out every key in my_dict.


#2

this:

(You should use print a, b rather than print a + " " + b.)

is a pretty good hint. use print a, b (without additional string) you currently use print a + b


#3

u recommend me use a + b?

for key in my_dict:
    print(key +  '' + my_dict[key])

have TypeError, TypeError: cannot concatenate 'str' and 'int' objects


#4

recommend to use:

a, b

not recommended:

a + b

#5

Oh, I'm sorry, i'ts my bad english.

Now, i'm try this:

my_dict = {
    "Name":"Anton",
    "Age": 23,
    "Address": True
}

for key in my_dict:
    print(key,my_dict[key])

Oops, try again. It looks like you did not print out every key in my_dict.

But reply a programm:

('Age', 23)
('Name', 'Anton')
('Address', True)

#6

parentheses = ()
why do you use parentheses? This is python2, print shouldn't have parentheses


#7

:fearful: Wooow, i didn't know that!! :unamused:
Thank you very much!! :flushed:


#8