Advertisement
makispaiktis

Python1 - Strings and Functions

Apr 5th, 2019 (edited)
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.66 KB | None | 0 0
  1. phrase = "Giraffe Is Tall Enough!";
  2. print("Upper: " + phrase.upper());
  3. print(phrase.isupper());
  4. print(phrase.upper().isupper());
  5. print(len(phrase));
  6. print("First character: " + phrase[0]);
  7. print("Last character: " + phrase[-1]);
  8. print("Last character: " + phrase[len(phrase) - 1]);
  9. print(phrase.index("s"));
  10. print(phrase.index("Tal"));
  11. print(phrase.replace("Giraffe", "Elephant"));                   # Κάνει replace στο string phrase χωρίς να αλλάζει την τιμή του
  12. print(phrase + "\n");
  13.  
  14. newPhrase = phrase.replace("Giraffe", "Elephant");
  15. print(newPhrase);
  16. print(len(newPhrase) - len(phrase));
  17. print(newPhrase.index("Ele"));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement