Adding two strings

A problem with your message format is that for students who you did not enjoy teaching, you don't want to tell them It's False that I enjoyed having you as a student. You want to only include the positive note for specific students.

As the first step to doing this, you decide to break out the message into two parts.

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

What do you get as the output?

SyntaxError: invalid syntax Hi Aditya. You achieved a score of 98.It's True that I enjoyed having you as a student. Hi Aditya. You achieved a score of 98. + It's True that I enjoyed having you as a student. TypeError: cannot concatenate 'str' objects

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...