How To Code in Python 3 by Lisa Tagliaferri

How To Code in Python 3 by Lisa Tagliaferri

Author:Lisa Tagliaferri
Language: eng
Format: epub
Publisher: DigitalOcean
Published: 2017-10-26T00:00:00+00:00


for x in range(1,4): sea_creatures += ['fish'] print(sea_creatures)

Output ['shark', 'octopus', 'blobfish', 'mantis shrimp', 'anemone', 'yeti crab', 'fish'] ['shark', 'octopus', 'blobfish', 'mantis shrimp', 'anemone', 'yeti crab', 'fish', 'fish'] ['shark', 'octopus', 'blobfish', 'mantis shrimp', 'anemone', 'yeti crab', 'fish', 'fish', 'fish']

For each iteration of the for loop, an extra list item of 'fish' is added to the original list sea_creatures.

The *= operator behaves in a similar way:

sharks = ['shark'] for x in range(1,4): sharks *= 2 print(sharks)



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.