InterviewSolution
Saved Bookmarks
| 1. |
Write a program to reverse a string using string slicing |
|
Answer» We have a STRING, "Hello World", which we want to REVERSE:1. The String to Reverse. TXT = "Hello World" [::-1] print(txt) ...2. Slice the String. txt = "Hello World" [::-1] ...3. Slice the String. def my_function(x): ...4. Return the String. def my_function(x): ...5. Call the Function. def my_function(x): ...6. Print the Result. def my_function(x): |
|