Skip to content

Python Palindromr #1690

Discussion options

You must be logged in to vote

Example with user input:

def get_country_input():
    while True:
        country = input("Enter a country name (or type 'done'): ")
        if country.lower() == 'done':
            break
        yield country  # Use a generator for potentially large inputs

country_list = list(get_country_input()) # Convert the generator to a list
palindrome_countries_user = check_palindrome_countries(country_list)

if palindrome_countries_user:
    print("\nPalindrome countries from user input:")
    for country in palindrome_countries_user:
        print(country)
else:
    print("\nNo palindrome countries found in the user input.")

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by vamsimessi10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants