Skip to content

Instantly share code, notes, and snippets.

@Chinmaytare
Created April 5, 2017 12:03
Show Gist options
  • Save Chinmaytare/04a3aec50976e91abdcb6cfcd45baf31 to your computer and use it in GitHub Desktop.
Save Chinmaytare/04a3aec50976e91abdcb6cfcd45baf31 to your computer and use it in GitHub Desktop.
Printing a list of multiplication table for any given number (in a python list form)
x = int(input("Enter a number to get its multiplication table: "))
z = int(input("Table upto?: "))
running = True
while running:
table = [[x, y, x * y] for y in range(1, z+1)]
for i in table:
print(i)
continue
print("Done.")
running = False
# Enter a number to get its multiplication table: 6
# Table upto?: 10
# Output:
# [6, 1, 6]
# [6, 2, 12]
# [6, 3, 18]
# [6, 4, 24]
# [6, 5, 30]
# [6, 6, 36]
# [6, 7, 42]
# [6, 8, 48]
# [6, 9, 54]
# [6, 10, 60]
# Done.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment