Skip to content

Instantly share code, notes, and snippets.

@MrDMurray
Last active October 5, 2016 19:27
Show Gist options
  • Save MrDMurray/cfb641074fd09c228483dd536e63573d to your computer and use it in GitHub Desktop.
Save MrDMurray/cfb641074fd09c228483dd536e63573d to your computer and use it in GitHub Desktop.
# this piece of code prints out characters and makes the list of words into uppercase
#The list as it is normally
inventory = ["pickaxe", "sword", "diamonds"]
print(inventory)
#Method 1: Using .upper each time
inventory = ["pickaxe".upper(), "sword".upper(), "diamonds".upper()]
print(inventory)
#OUTPUT LOOKS LIKE THIS: ['PICKAXE', 'SWORD', 'DIAMONDS']
#Method 2: Using a for Loop
inventory = ["pickaxe", "sword", "diamonds"]
for x in inventory:
x=x.upper()
print(x)
"""
OUTPUT LOOKS LIKE THIS:
PICKAXE
SWORD
DIAMONDS
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment