Skip to content

Lesson 2

Why repeat manually when you can for loop

for i in range(30):
    print("I will never win an enemy")

Variable substitution

sentence_mon  = "I will never win an enemy"
sentence_tues = "I will be nice"

Take an input instead of hard code

sentence_mon  = "I will never win an enemy"
sentence_tues = "I will be nice"

repeat = input("how many times : ")

for i in range(int(repeat)):
    print(sentence_mon)

Printing $ 5 times

print("$" * 5)

Homework

Input how many $ would you like? :

Code

  • Take an input from the terminal
  • Using the code from above substitue 5 with the input value
  • Make as many mistakes as you like
  • Don't give up

Output $$$$$$