Error when trying to do list compression with new lines Unterminated expression in f-string; missing close brace
Question:
test2 = [1,2,3,4,5]
print(f'The following Attributes are not supported n {"n".join([str(i) for i in test2])}')
Intended output:
The following Attributes are not supported
1
2
3
4
5
Is there any way I could achieve this whilst keeping it on the same line? The error received is as follows: Unterminated expression in f-string; missing close brace
Answers:
You can use chr(10)
instead of 'n'
:
print(f'The following Attributes are not supported n{chr(10).join([str(i) for i in test2])}')
test2 = [1,2,3,4,5]
print(f'The following Attributes are not supported n {"n".join([str(i) for i in test2])}')
Intended output:
The following Attributes are not supported
1
2
3
4
5
Is there any way I could achieve this whilst keeping it on the same line? The error received is as follows: Unterminated expression in f-string; missing close brace
You can use chr(10)
instead of 'n'
:
print(f'The following Attributes are not supported n{chr(10).join([str(i) for i in test2])}')