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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:36:38+00:00 2026-06-13T18:36:38+00:00

This is supposed to be part of a function that replaces consonants with ‘$’

  • 0

This is supposed to be part of a function that replaces consonants with '$' until the "ch" character is reached, where it will then stop.

Examples:

vowels_or_not(‘abcdeAghi’, ‘A’) should return ‘a$$$e’

vowels_or_not(‘aaaaA’, ‘A’) should return ‘aaaa’

My issue is that it isn’t doing anything if the input string is only one character long. vowels_or_not(a, X) should return a and vowels_or_not(x, A) should return $. Everything else works fine. I tried fixing it but I still don’t see anything wrong with the code, but then again I’m a beginner! Any help would be greatly appreciated.

def vowels_or_not (st, ch)
    vowels = ('a','e','i','o','u','A','E','I','O','U')
    flag = True
    a = 0
    aux = ''
    while flag is True:
        for i in range(len(st)):        
            if (st[i] == ch):
                flag = False
                break
            else:
                if (st[i] in vowels):
                    aux = aux + st[i]
                    a = a + 1
                if (st[i] not in vowels):
                    aux = aux + '$'
                    a = a + 1
    return aux
  • 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-13T18:36:39+00:00Added an answer on June 13, 2026 at 6:36 pm

    Your problem is your while loop never ends if the last character in st isn’t the same as ch.

    But you don’t really need that while loop as it is redundant, you only need the for-loop:

    def vowels_or_not(st, ch):
        vowels = ('a','e','i','o','u','A','E','I','O','U')
        a = 0
        aux = ''
        for i in range(len(st)):
            if (st[i] == ch):
                break
            else:
                if (st[i] in vowels):
                    aux = aux + st[i]
                    a = a + 1
                if (st[i] not in vowels):
                    aux = aux + '$'
                    a = a + 1
        return aux
    

    >>> vowels_or_not('a', 'X')
    'a'
    >>> vowels_or_not('aaaAX', 'X')
    'aaaA'
    >>> vowels_or_not('aaabX', 'X')
    'aaa$'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is part of an assignment. Everything that's supposed to work, already works, but
I have this function that is supposed to query the database every 4 seconds
this is part of my code which reads an http response. It's supposed to
I've written a function that's supposed to (1) generate a random number, (2) judge
I have spent many hours working on this program that is supposed to play
I am doing work for school, I'm supposed to write a function that accepts
Below is a function I found about a year ago that is supposed to
I have a function I've written that was initially supposed to take a string
I'm supposed to implement a function that erases a range of values from containers.
This is supposed to work yet just says no stocks table - supposed lost

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.