44.5k views
2 votes
1|>if "!!!" in a_string:

2|>>print("You're really excited!")
3|>elif "!!" in a_string:
4|>>print("You're pretty excited!")
5|>[fill in this blank]
6|>>print("You're excited!")
7|>else:
8|>>print("Are you bored?")
Q: The code above prints "You're really excited!" if a_string has the text "!!!" in it, and ""You're pretty excited!" if a_string has the text "!!" in it.
If inserted into the blank, which of the following segments of code will print "You're excited!" if a_string has the text "!" in it, but only if a_string did not also have "!!" or "!!!" in it, and still print "Are you bored?" only if the string has no exclamation points in it?

1 Answer

1 vote

Final answer:

To print "You're excited!" if the string has the text "!" but not "!!" or "!!!", add the elif statement, and modify the else block to print "Are you bored?"

Step-by-step explanation:

The code snippet provided already checks for the presence of "!!!" and "!!" in the input string. To print "You're excited!" if the string has the text "!" but not "!!" or "!!!", you can add the following code in the blank:

elif "!" in a_string:
print("You're excited!")

This code will only execute if the string has the text "!" and does not have "!!" or "!!!" in it. Finally, the else block can be modified to print "Are you bored?" if the string doesn't have any exclamation points, resulting in:

else:
print("Are you bored?")

User GDICommander
by
8.1k points