Skip to content

Python documentation

ExWiCo edited this page Apr 30, 2023 · 4 revisions

How to write effective code

1

TURN THIS: print("There was a man named " + character_name + ".") INTO THIS: print(f"There was a man named {character_name}.")

2

TURN THIS:
inp = input()
if inp == "a":
print(1)
elif inp == "A":
print(1)

3

INTO THIS:
inp = input()
if inp == "a" or inp == "A": #1
print(1)

4

TURN THIS: a, A = 1, 1 INTO THIS: a = A = 1

5

TURN THIS: i = i + 1 INTO THIS: i += 1

Clone this wiki locally