💡 For the best experience, set your browser zoom level to 75%

    ‎75%‎ للحصول على أفضل تجربة، اضبط مستوى تكبير المتصفح على 💡

Skip to main content

Lesson 4 - Assignment

Objective:

Apply string indexing, slicing, case conversion, and string checking in Python. 

Tasks:

1.    Create a string variable called message and assign it the value:
" The best things in life are free! "

2.    Perform the following actions on the message variable:

o   Print the original string.

o   Use strip() to remove extra whitespace.

o   Check if the word "free" is in the message using an if statement, and print an appropriate message.

o   Print the string in both uppercase and lowercase.

o   Print the length of the string using len().

o   Slice and print characters from position 4 to 9.