Python-lists

From wikipost
Revision as of 15:27, 17 December 2020 by Admin (talk | contribs)
Jump to navigationJump to search

parsing lists in python


Python uses lists and sets (aka dictionaries)

  • Lists have square brackets
[1, 2, 3]
["green", "red", "blue"]
["name", [43, 35, 14, 77], "blue", 2018]
  • Sets have curly braces


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


2 dimensions