Skip to content

Instantly share code, notes, and snippets.

@wynand1004
Created October 5, 2017 00:44
Show Gist options
  • Save wynand1004/d259a39b8b8e4dcc412f61730627a497 to your computer and use it in GitHub Desktop.
Save wynand1004/d259a39b8b8e4dcc412f61730627a497 to your computer and use it in GitHub Desktop.
Seven Python Loop Challenges using Strings
# Loop Challenges
# Solution Video at https://youtu.be/RO7x4qPM8aY
# Subscribe to my YouTube Channel at https://www.youtube.com/channel/UC2vm-0XX5RkWCXWwtBZGOXg/playlists
# Follow me on Twitter @tokyoedtech
import os
os.system("clear")
print("1.")
# Create a loop that prints the string vertically
text = "abcdefghijklmnopqrstuvwxyz"
print("\n\n2.")
# Create a loop that will print the string horizontally by adding each letter to message
text = "abcdefghijklmnopqrstuvwxyz"
message = ""
print (message)
print("\n\n3.")
# Create a loop that prints the string backwards
text = "abcdefghijklmnopqrstuvwxyz"
message = ""
print (message)
print("\n\n4.")
# Create a loop that prints every other letter of the following string
text = "Ie ghuakdg ray wgsrdefagtt ytuiimoef vodnd aevx,cjuyrdsqiqoana!x"
message = ""
print (message)
print("\n\n5.")
# Create a loop that prints only the capital letters
text = "HrhIooRefOenSqsHbaIifMcqAae nIfkSqi hAig kBioEquAmgUqrTxIzFvUfLg lCoIiTyYg!g"
message = ""
print (message)
print("\n\n6.")
# Create a loop that counts the number of capital letters and lowercase letters
capitals = 0
lowercase = 0
text = "aHfKJHgfOIUDrkjhkjnOInhdjbkjhdgkjlnhJHDDHkjVDhgDJ"
print ("Capitals: {}".format(capitals))
print ("Lowercase: {}".format(lowercase))
print("\n\n7.")
# Super challenge
# Create a loop that prints only letters that are doubled
# Print them as capitals
# For example, SsuiaAowccprR34eEp9Dd = SACRED
text = "1gGpoO3 bsS9ayYy6mmwebB2hAAl97sS"
message = ""
print(message)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment