Skip to content

Instantly share code, notes, and snippets.

@codeboy101
Last active January 7, 2016 05:56
Show Gist options
  • Save codeboy101/575aa554d559777cd36d to your computer and use it in GitHub Desktop.
Save codeboy101/575aa554d559777cd36d to your computer and use it in GitHub Desktop.
##okay so we want to make a list of square of numbers 1 to 5 :
## so we can do it like this :
square_list = []
for i in range(1,6) :
square_list.append(i**2)
print(square_list)
## or by using list comprehension :
square_list = [i**2 for i in range(1,6)]
# a dictionary showing number:square of number
square_dict ={n:n**2 for n in range(1,6)}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment