greeting = ['Hello', 'World']
This particular list contains two string values. Lists can contain any type of value, and different types can be mixed together in the same list.
List values can span multiple lines. Here is the same list formatted a bit differently.
greeting = [
'Hello',
'World'
]
Trailing commas
The last item in a list can be followed by an optional "trailing comma". This comma has no effect, but Python allows it so you don't have to treat the last value differently from the others.greeting = [
'Hello',
'World', # notice the trailing comma
]
No comments:
Post a Comment