Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions improve_me.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import random, getopt, sys, os

# This line will only work in Python 2
print "This script is not perfect"
print "This script is not perfect, but slightly better"

# The following loop could be written in a single line with list comprehension
random_numbers = []
Expand All @@ -14,10 +14,10 @@
print random_numbers[i]

# This loop could be rewritten with enumerate
i = 0
for r in random_numbers:

for i,r in enumerate(random_numbers):
print(i, r)
i += 1

# This is not C
if(len(random_numbers)>5): print("Lots of random numbers here")
if(len(random_numbers)>5):
print("Lots of random numbers here")