Code works in VS Code and online compilers but not in IDLE

My code runs perfectly fine in VS Code and online compilers but not in IDLE.

Expected Output (that is produced in VS Code too): https://i.stack.imgur.com/uWpuY.png.
Actual Output in IDLE: https://i.stack.imgur.com/VZ9Bo.png

Code:

row_symbol = ['A','B','C','D']
col_symbol = ['1','2','3','4']

# Prints first row of row symbol. ie A,B,C,D
print('{:2}'.format(''), end = '')
for i in row_symbol:
    print('{:^6}'.format(i), end = '')
print()

# Prints second row
print('{:1}'.format(''), end = '')
for i in range(4):
    print('+-----', end = '')
print('+')

# Prints the rest of the rows
for i in range(4):
    print('{}'.format(col_symbol[i]), end = '')
    for z in range(4):
        print('|{:<5}'.format(' '), end = '')
    print('|')
    print('{:1}'.format(''), end = '')
    for z in range(4):
        print('+-----', end = '')
    print('+')

Please help! Thank you in advance :)



Read more here: https://stackoverflow.com/questions/68462655/code-works-in-vs-code-and-online-compilers-but-not-in-idle

Content Attribution

This content was originally published by YaoJie at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: