Hi, everyone. I started learning Python recently, but there were a lot of errors, so I'm asking you a questionㅜ<
What I want is to use the print_table(13) function
0 1 2 3
4 5 6 7
8 9 10 11
12 13
I want it to be like this, but I keep getting a syntax error about what's wrong (I saved the numbers up there as a file called numbers.txt)
f = input('numbers: ')
infile = open(f, 'r')
contents = infile.readlines()
infile.close()
table = []
def print_table(table):
for row in table:
print(' '.join(row))
Can you tell me the wrong place? Thank you!
python
In the question, you receive two parameters, such as print_table (13 and 4). The code has one parameter.
I don't understand the file input part, but I think print_table can do this.
def print_table(max, col):
for i in range(max+1):
print("{}\t".format(i),end='')
if (i+1)%col == 0:
print("")
print("")
print_table(13,4)
© 2024 OneMinuteCode. All rights reserved.