Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # While "keepGoing" is "True", we will keep processing user input.
- while keepGoing :
- #Getting the string from the user
- string = input ("Please enter the string: ")
- #Generating a cleaned-up version of the inputted string
- lower_string = string.lower()
- clean_string = lower_string.replace (" ", "")
- #Print the cleaned-up version of the inputted string
- print ("The cleaned-up string is:", clean_string)
- #Determine the length of the word
- length= len(clean_string)
- half_length = int(length/2)
- print ("It has", length, "letters.")
- #Determined if the cleaned-up string is a palindrome through Boolean variable
- for i in range(0, half_length):
- if string [i] == string[len(string)-i-1]:
- is_palindrome = 1
- else:
- is_palindrome = 0
- if is_palindrome == 1:
- mirrored = clean_string [0:half_length]
- print ('This IS a palindrome. The mirrored part is "', mirrored, '".')
- else:
- print("This is NOT a palindrome.")
- #Ask the user if they want to continue inputting another string to see if it is a palindrome
- response = input("Would you like to check another string? [Yes/ No] ")
- if response== "No":
- keepGoing = False
- print ("Goodbye.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement