Created
June 8, 2022 04:23
-
-
Save tjhartline/1577501ba477286cd579ab78cdf7d970 to your computer and use it in GitHub Desktop.
Multiplication list in python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user_input= input() | |
lines = user_input.split(',') | |
# This line uses a construct called a list comprehension, introduced elsewhere, | |
# to convert the input string into a two-dimensional list. | |
# Ex: 1 2, 2 4 is converted to [ [1, 2], [2, 4] ] | |
mult_table = [[int(num) for num in line.split()] for line in lines] | |
for row in mult_table: | |
print(" | ".join([str(cell) for cell in row])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment