I tried to use \n but it gives back an error. Am I using it wrong?
list1 = [1, 2, 3]
list2 = [4, 5, 6]
list3 = list1 + list2
list4 = [list1 + list2]
print(list3, list4)
The result should be:
[1, 2, 3, 4, 5, 6]
[[1, 2, 3, 4, 5, 6]]
I tried to use \n but it gives back an error. Am I using it wrong?
list1 = [1, 2, 3]
list2 = [4, 5, 6]
list3 = list1 + list2
list4 = [list1 + list2]
print(list3, list4)
The result should be:
[1, 2, 3, 4, 5, 6]
[[1, 2, 3, 4, 5, 6]]
You may reach your answer by formatting the string.
list1 = [1, 2, 3]
list2 = [4, 5, 6]
list3 = list1 + list2
list4 = [list1 + list2]
print(f'{list3}\n{list4}')
Output:
[1, 2, 3, 4, 5, 6]
[[1, 2, 3, 4, 5, 6]]
Have Fun :)
You can do this by using 'sep':
list1 = [1, 2, 3]
list2 = [4, 5, 6]
list3 = list1 + list2
list4 = [list1 + list2]
print(list3, list4,sep='\n')
Output:
[1, 2, 3, 4, 5, 6]
[[1, 2, 3, 4, 5, 6]]
You need to put the arguments like this in print :
print(list3,'\n', list4)
And the output will be :
[1, 2, 3, 4, 5, 6]
[[1, 2, 3, 4, 5, 6]]
Or
print(list3)
print(list4)
Not the cleanest solution but you can do the following:
print(list3,'\n'+str(list4))