Difference between revisions of "Python-lists"

From wikipost
Jump to navigationJump to search
(Created page with "parsing lists in python <pre> my_list = [28, 56, 45] for item in my_list: print(item) </pre> Output: <pre> 28 56 45 </pre>")
 
Line 2: Line 2:
  
  
 +
===just numbers===
  
 
<pre>
 
<pre>
Line 16: Line 17:
 
56
 
56
 
45
 
45
 +
</pre>
 +
 +
 +
 +
===just words===
 +
<pre>
 +
my_list = ["green", "red", "blue"]
 +
 +
for item in my_list:
 +
  print(item)
 +
</pre>
 +
 +
Output:
 +
<pre>
 +
green
 +
red
 +
blue
 
</pre>
 
</pre>

Revision as of 15:07, 17 December 2020

parsing lists in python


just numbers

my_list = [28, 56, 45]

for item in my_list:
  print(item)

Output:

28
56
45


just words

my_list = ["green", "red", "blue"]

for item in my_list:
  print(item)

Output:

green
red
blue