Created
October 5, 2016 19:30
-
-
Save MrDMurray/1e3f03e110ae9ca16164d58607bb0a56 to your computer and use it in GitHub Desktop.
STJLOL-DMU Using forloops
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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