Reputation: 27
I'm trying to get the python shell to display this print statement without the large gap at the backslash. I have already tried going into Source > Fix indentation.
print('\nAverage median \
income in {:2s}: ${:<10,.2f}'.format(state, income))
Average median income in MI: $51,601.37
Any guidance helps, thanks!
Upvotes: 0
Views: 241
Reputation: 2133
This is not a Spyder problem. It's your code. I think your backslash was intending to separate a line of code across two lines, but the backslash must be outside of your string, otherwise you're just escaping a space inside a string. If you must keep the code separated on two lines while preserving indentation, simply close your quotes and reopen them, keeping the backslash outside the quotes:
print('\nAverage median ' \
'income in {:2s}: ${:<10,.2f}'.format(state, income))
Average median income in MI: $51,601.37
Upvotes: 0
Reputation: 26
Try removing the tab before 'income' in ur code print('\nAverage median \income in {:2s}: ${:<10,.2f}'.format(state, income))
Upvotes: 1