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 8616143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:32:53+00:00 2026-06-12T05:32:53+00:00

I am attempting to replace multiple letters within a string, I want the vowels

  • 0

I am attempting to replace multiple letters within a string, I want the vowels to be replaced by the users input, and my current code replaces all the vowels with the same letters, however I want to replace the vowels with different user inputs. Below is an example of what I would like, and the code below that.

What I want

input1 = zz
input2 = xx
input3 = yolo

output = yzzlxx

What I have

input1 = zz
input2 = xx
input3 = yolo

output = yzzlzz

Here is my code.

def vwl():
    syl1 = input("Enter your first syllable: ")
    syl2 = input("Enter the second syllable: ")
    translate = input("Enter word to replace vowels in: ")

    for ch in ['a','e','i','o','u']:
        if ch in translate:
            translate=translate.replace(ch,syl1,)

    for ch in ['a','e','i','o','u']:
        if syl1 in translate:
            translate=translate.replace(ch,syl2,)

    print (translate)
  • 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-12T05:32:55+00:00Added an answer on June 12, 2026 at 5:32 am

    The method replace takes an additional argument count:

    translate=translate.replace(ch,syl1,1)
    break # finish the for loop for syl1
    

    will only replace the first instance of ch and break will ensure you don’t replace any subsequent vowels with syl1.

    Similarly:

    translate=translate.replace(ch,syl2,1)
    break # finish the for loop
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am attempting to replace multiple lines using sed on a Linux system Here
I'm attempting to replace a pattern in all my .aspx and .ascx file when
I am attempting to do a quick replace of the 'innerHTML' of the 'code'
I am attempting to replace all records for a give day in a certain
I'm attempting to replace all <foo> elements in a DOMDocument with <bar> elements. The
I am essentially attempting to replace all of the footnotes in a large text.
I'm attempting to replace url's in a string by calling a function that shortens
I am attempting to replace some undesirable characters in a string retrieved from an
I am attempting to replace the first occurrence of the string [] in another
I'm attempting to find and replace a string of text, but it doesn't seem

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.