-
Notifications
You must be signed in to change notification settings - Fork 2
How to write effective code
TURN THIS:
print("There was a man named " + character_name + ".")
INTO THIS:
print(f"There was a man named {character_name}.")
TURN THIS:
inp = input()
if inp == "a":
print(1)
elif inp == "A":
print(1)
INTO THIS:
inp = input()
if inp == "a" or inp == "A": #1
print(1)
TURN THIS:
a, A = 1, 1
INTO THIS:
a = A = 1
TURN THIS:
i = i + 1
INTO THIS:
i += 1
TURN THIS:
message_pt1 = "Veritas"
message_pt2 = "means \"truth\"."
print(f"\n{message_pt1} {message_pt2}")
INTO THIS:
message = ["Veritas", "means \"truth\"."]
print(f"\n{message[0]} {message[1]}")
TURN THIS:
accepted_1 = "cage"
accepted_2 = "dragon"
accepted_3 = "key"
guess = input("Give me a password: ")
if guess == accepted_1 or guess == accepted_2 or guess == accepted_3:
print("Hi")
INTO THIS:
accepted_passwords = ["cage", "dragon", "key"]
guess = input("Give me a password: ")
if guess in accepted_passwords:
print("Hi")