Palindromes
Next, you are committed to finding any peculiarity in the words included in the movie review dataset. A palindrome is a sequence of characters that can be read the same backward as forward, for example: Madam or No lemon, no melon. You realize that some funny movie names can have this characteristic. You want to make a list of all movie titles that are funny palindromes but you will start by analyzing one example.
In python, you can also specify steps by using a third index. If you don't specify the first or second index and the third one is negative, it will return the characters jumping and backward.
The text of a movie review for one example has already been saved in the variable movie. You can use print(movie) to view the variable in the IPython Shell.
이 연습은 강의의 일부입니다
Regular Expressions in Python
연습 안내
- Extract the substring from the 12th to the 30th character from the variable
moviewhich corresponds to the movie title. Store it in the variablemovie_title. - Get the palindrome by reversing the string contained in
movie_title. - Complete the code to print out the
movie_titleif it is a palindrome.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
# Get the word
movie_title = ____[____]
# Obtain the palindrome
palindrome = ____[____]
# Print the word if it's a palindrome
if movie_title == palindrome:
print(____)