0
Help me to fix the error??
a = input() j = 0 for i in a: if i != 'a' and i != 'e' and i != 'i' and i != 'o' and i != 'u': i = "|"+i else: i = i+"|" print(a)
10 Answers
+ 3
Shahir ,
if you really have a problem, we need some more details from you:
âȘïžgive a clear and complete description about your task
âȘïžif there are error messages please post them here
âȘïžgive at least one sample with input data and the expected output
âȘïžto be able to find out the issues you have, we need to see your code
   => please put your code in playground, save it there and post a link to it here.
thanks for your understanding!
+ 1
Almost same code little above.
+ 1
If I enter a vowel then it should output that vowel along with "|"
Example:
Input:a
Output:a|
Input:s
Output:|s
+ 1
If input is "a"
As "a" is a vowel it should print like "a|"
If input is "f"
As "f" is not a vowel it should print like "|f"
And if you enter a string then
Input:lothar
Output:|l
o|
|t
|h
a|
|r
As "l" is not a vowel so it prints "|l"
And as "o" is vowel so it prints "o|"
.......
Hope you understand
Ask me if you don't understand
+ 1
vow="aeiou"
x = "hello world"
x = x.lower()
z = ''
for i in x:
if i in vow:
z+="i+"|"
elif i.isalpha() and i not in vow:
z+="|"+i
else:
z+=i
print(z)
+ 1
1.You loop through the string,
and it is bad practice to change item(s) of list during iteration.
2. string is immutable.
So trying assign new value to any item of string causes error.
+ 1
Import re
a=input(âenter a letter:â)
pattern=râ[a|o|u|i|e]â
match=re.match(pattern,a)
if match:
print(fâ{a}|â)
else:
print(fâ|{a}â)
0
Thanks but why my code isn't working properly??
0
Shahir
You haven't changed the string at all. Simply changing the value of iterable won't make any change in strings in python. Just use .replace method just as I did. Hope it's clear to you...
https://code.sololearn.com/cdAfzq5X47tj/?ref=app