-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5bda5d2
commit 77ca93c
Showing
2 changed files
with
23 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
# Flattening a nested list | ||
# Palindrome is a word, phrase, or sequence that reads the same backwards as forwards, e.g. madam or nurses run. | ||
# Checking if a string is a palindrome | ||
|
||
my_list = [[1,2], [3,4], [5,6]] | ||
flattened_list = [x for sublist in my_list for x in sublist] | ||
print(flattened_list) | ||
my_string =input('Enter a string to check if it is a palindrome: ') | ||
|
||
if my_string[::-1] == my_string: | ||
print(my_string, "is a palindrome.") | ||
else: | ||
print(my_string, "is not a palindroe.") |