Reputation: 103
I'm trying to submit this into myprogramminglab, everything else is correct but it wants me to remove this whitespace that doesn't seem to exist.
num_males = int(input('Enter number of males:'))
num_females = int(input('Enter number of females:'))
total_students = num_males + num_females
percent_male = num_males * 100 / total_students
percent_female = num_females * 100 / total_students
print('Percent males: {:.0f}%' .format(percent_male)**X**,
'\nPercent females: {:.0f}%' .format(percent_female))
I labeled where the spacing is with an X
Am I just not seeing something?
Upvotes: 2
Views: 62
Reputation: 14423
When you pass multiple arguments to print
, spaces are inserted between each value by default. If you want to suppress the space separators, set the sep
keyword argument to an empty string:
print(
'Percent males: {:.0f}%' .format(percent_male),
'\nPercent females: {:.0f}%' .format(percent_female),
sep='',
)
Alternatively, you could pass a single string to print
to avoid the separator behavior entirely:
print("Percent males: {:.0f}%\nPercent females: {:.0f}%".format(
percent_male,
percent_female,
))
Upvotes: 3