Created
December 13, 2016 19:42
-
-
Save joetechem/c80c51632b46d71d47f39c8157817792 to your computer and use it in GitHub Desktop.
a simple gist to show how you can use a for loop and create a variable to use that variable
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
# A simple program to demonstrate using a for loop | |
# To print hello world! five times in Python, you could type | |
# print('hello world!') five times, each on its own line | |
# Or, you could use a 'for loop' to have the same result with less typing: | |
for x in range (0, 5): | |
print('hello world!') | |
# The range function can create a list of numbers ranging from a starting number | |
# to the number just before the ending number. | |
# Create a variable then use that variable | |
name = 'name' | |
for x in range(0, 5): | |
print(name) | |
# OR | |
for i in range(5): | |
print(name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment