The first maketrans arguments must have equal length

string = input("Input:")

# Remove using trans()

remove_string =string.translate(str.maketrans(',' , 'aeiouAEIOU'))

print(f"Ouput:{remove_string}")

i getting above error,help please.

Can you provide a link to the challenge for this code?

i am solving cs50p problem set, , implement a program that prompts the user for a str of text and then outputs that same text but with all vowels (A, E, I, O, and U) omitted, whether inputted in uppercase or lowercase. This is the question but i couldn’t identify where it went wrong

If you pass two arguments to the maketrans function, the strings must be equal length. You passed ',' as the first argument and 'aeiouAEIOU'. What are you hoping to accomplish with str.maketrans(',' , 'aeiouAEIOU')? Do you have to use maketrans and translate to solve the problem or can you use whatever code you want?

I want to remove vowels from my output. if I input twitter it should be remove vowels and gave output without i and e, without any casesensitivity

I understand the task. I was asking do you have to use maketrans or translate to solve the problem. It can be solved without them.

i tried with loop but i couldn’t get remove method, #print(str.translate({ord(letter): None for letter in ‘aeiou’}))
method worked but when it comes to case it will give trouble, hence i changed my code like above and it doesnt work as expected. i got confused, i am very new to programming.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.