Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8570553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:35:05+00:00 2026-06-11T18:35:05+00:00

I created a program where you enter in a word, and certain text is

  • 0

I created a program where you enter in a word, and certain text is added before each vowel in the inputted word. The program will ask the user to play again until a ‘n’ for no is entered.

However, when a ‘y’ is entered it keeps playing, but what happens is this:

First time running the program:

Enter first syllable: ip
Enter second syllable: *zz
Enter word to translate: gibberish
Your translated word is: gipibbezzerizzish
Would you like to play again(y/n)? y
Enter first syllable: ip
Enter second syllable: *zz
Enter word to translate: gibberish
Your translated word is: gizzibbezzerizzish
Would you like to play again(y/n)? 

The first result, “gipibbezzerizzish” is correct. The second time it runs, there is an error, it results “gizzibbezzerizzish” which is incorrect.

At the end of the loop what I did is make final_str = “” so when it starts backup, its empty, but for some reason this doesn’t work? What’s wrong here?

I’m using Python 3.2.3.

Code:

vowels = "aeiou"
playagain = ""
wildcard = '*'
final_str = ""
vowelcount = 0
first_vowel_count = True
second_vowel_count = False

while playagain != "n": ## If playagain is not no, then keep going.
    first_syl = input('Enter first syllable: ')
    second_syl = input('Enter second syllable: ')
    word = input('Enter word to translate: ')
    for ch in word: ## Run loop for all characters in the entered word.
        if ch.lower() not in vowels: ## Checks if ch is vowel or not in word.
            first_vowel_count = True
            vowelcount += 1
        elif wildcard in first_syl and vowelcount <=2: ## Checks for first wildcard.
            final_str += ch + first_syl[1::] ## For first wildcard, remove * and add the vowel (ch) and the first_syl.
            first_vowel_count = False
            second_vowel_count = True
        elif first_vowel_count and vowelcount <= 2: ## If there is no wildcard, but a vowel, run this loop.
            final_str += first_syl       
            first_vowel_count = False
            second_vowel_count = True
        elif wildcard in second_syl: ## For second wildcard, remove * and add the vowel (ch) and the first_syl.
            final_str += ch + second_syl[1::]     
            first_vowel_count = False
            second_vowel_count = True
        elif second_vowel_count: ## If there is no wildcard, but a vowel, run this loop.
            final_str += second_syl
            second_vowel_count == False
        final_str += ch ## Finally, this is the resulting string to be printed.
    if playagain != "n": ## Ask user to play again.
        print("Your translated word is:", final_str) ## Print the word that has just been translated.
        playagain = input("Would you like to play again(y/n)? ") ## Then ask user to play again.
        final_str = "" ## Reset the string if playagain = "y" and start from the top.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T18:35:06+00:00Added an answer on June 11, 2026 at 6:35 pm

    Having that code in an if statement at the bottom is unnecessary, you wouldn’t be in the while loop if playagain were 'n'.

    Anyway, final_str definitely gets reset there- but you also need to reset vowelcount, first_vowel_count, and second_vowel_count. You’re probably better off just setting those at the beginning of the loop so as to be DRY.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I created a dynamic UI that shows each module that the user has added
I've created a program that will allow users to log in and enter the
The program, asks the user to enter the number of processes to be created
I have created a regex that only allows the user to enter numbers and
This program allows a user to calculate to enter sales and calculate sales taxes
I have created the output for a program that allows a user to input
I have created a C program which updates user name with client input, but
in Python, I have created a text generator that acts on certain parameters but
I'm currently working on a program that asks a user to enter a secret
I created a program that will use a dynamic array by using pointer to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.