I have a file named numbers.txt and this is the content:
1
2
3
4
This is the code I used to read the lines in numbers.txt:
with open("numbers.txt") as numbers:
for number in numbers:
try:
print(number + ' is a number!')
except Exception as e:
print(e)
Output:
1
is a number!
2
is a number!
3
is a number!
4 is a number!
I wanted it to output this:
1 is a number!
2 is a number!
3 is a number!
4 is a number!
How can I get this output?