Run Program ❯
Python Home
❯
Run Code
Change Orientation
# String declaration greeting = "Hello" name = "Alice" message = greeting + ", " + name + "!" # Display the string and its type print("Message:", message) print("Type of message:", type(message)) # String length print("\nLength of message:", len(message)) # Accessing characters in the string print("First character:", message[0]) print("Last character:", message[-1]) # String slicing print("Sliced (Hello):", message[0:5]) # String methods print("Uppercase:", message.upper()) print("Lowercase:", message.lower()) print("Does it start with 'Hello'? -", message.startswith("Hello")) print("Does it end with '!'? -", message.endswith("!"))