Please enable JavaScript.
Coggle requires JavaScript to display documents.
Python
Statement - Coggle Diagram
Python
Statement
-
for
loop
list
lst = [(1,2), (3,4)]
for item in list:
print(item)
(1,2)
(3,4)
lst = [(1,2), (3,4)]
for (a,b) in lst:
print(a)
print(b)
1
2
3
4
for a,b in list:
print(a)
1
3
dictionary
dic = {'k1':1, 'k2':2}
for item in dic:
print(item)
k1
k2
for item in dic.items():
print(item)
('k1', 1)
('k2',2)
for key, value in dic.items()
print(value)
or
for value in dic.values()
1
2
-
useful
operators
-
in enumerate()
word = 'hello'
for x in enumerate(word):
print(x)
(0, h)
(1, e)
...
for index, letter in enumerate(word):
print(index)
print(letter)
zip(a,b)
-
tup1 = (1,2)
tup2 = ('a', 'b')
tup = zip(tup1, tup2)
tup = ((1,'a'), (2,'b'))
-
-
-
-
-
-