Exercise: Test multiple conditions in if statement
Let's apply what you've learned about conditional statements along with knowledge from previous chapters. Complete the
if
-condition to check if the length of text is greater than 5 and if the last character is 'k'. Use logical operators and string indexing for this task.text = 'New York'
# condition: length of text > 5 and last character 'k'
if
text += ' City'
print(text)
# expected output: New York City
Python
Setting up Python environment...
Output