|
| 1 | +# my_string = "Hello World hello" |
| 2 | +# |
| 3 | +# print(my_string[-7:-2]) |
| 4 | +# |
| 5 | +# print(my_string[-1]) |
| 6 | +# |
| 7 | +# print(my_string.upper(), my_string.capitalize(), my_string.lower(), my_string.replace("o", "0", 2)) |
| 8 | +# |
| 9 | +# print(my_string.rindex('o')) |
| 10 | +# |
| 11 | +# print(my_string.upper()[3:].startswith('L')) |
| 12 | + |
| 13 | +# name = 'Cookie' |
| 14 | +# print("Hello {}.".format(name)) |
| 15 | +# print("Hello %s." % name) |
| 16 | +# print(f"Hello {name}.") |
| 17 | + |
| 18 | +# print("C" in name) |
| 19 | +# print("Hello" in name) |
| 20 | +# print(len(name)) |
| 21 | + |
| 22 | +# print(str(42)) |
| 23 | +# print(float("42.44")) |
| 24 | +# print(int("42")) |
| 25 | + |
| 26 | +# Exercise |
| 27 | + |
| 28 | +# print("Hello!") |
| 29 | +# word1 = input("Enter something: ") |
| 30 | +# word2 = input("Enter another thing: ") |
| 31 | +# word3 = input("Enter a third thing: ") |
| 32 | +# word4 = input("And yet another thing: ") |
| 33 | +# # Usable everywhere |
| 34 | +# print("You entered %s, %s, %s, %s." % (word1, word2, word3, word4)) |
| 35 | +# print("You entered {}, {}, {}, {}.".format(word1, word2, word3, word4)) |
| 36 | +# # Only usable in Python 3.6 |
| 37 | +# print(f"You entered {word1}, {word2}, {word3}, {word4}.") |
| 38 | + |
| 39 | +message = input("What do you want me to say? ") |
| 40 | +message = message.upper() |
| 41 | +print(message, "!!!") |
| 42 | +print(message, "!!!") |
| 43 | +print(message, "!!!") |
| 44 | + |
| 45 | +if message[::-1] == message: |
| 46 | + print("It's a palindrome!") |
| 47 | +else: |
| 48 | + print("It's not a palindrome") |
0 commit comments