Printing two strings

Uh-oh. In the previous problem,

1
print message + extra

did not give you the output you wanted, because the two sentences came out stuck together, with no space after the period in the first sentence.

You decide to try again. How do you edit your program:

1
2
3
4
5
6
7
8
name = "Aditya"
score = 98
liked = True

message = "Hi %s. You achieved a score of %d." % (name, score)
extra = "It's %s that I enjoyed having you as a student." % liked

print message + extra

so that the output for Aditya is:

1
Hi Aditya. You achieved a score of 98. It's True that I enjoyed having you as a student.

All of these would give the desired output Make message = "Hi %s. You achieved a score of %d in the class. " Instead of print message + extra, use print message + ' ' + extra Instead of print message + extra, use print message, extra

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

0 solutions

No explanations have been posted yet. Check back later!

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...