+ 2

# How to compare string characters with itself?

I want to remove vowels from a string and if a string has vowels consecutively then print the given string ex: map= mp feel = feel heal= heal

26th Jan 2022, 12:28 PM
+ 7
a=str(input('enter the word')) vowels='aeiou' z='' n=0 for i in range(0,len(a)-1): n+=1 if (a[i] in vowels) and (a[i+1] in vowels): break if n == len(a)-1: for i in range(0,len(a)): if a[i] not in vowels: z+=a[i] print(z) if len(z)==0: print(a) Finally this worked
26th Jan 2022, 2:37 PM
+ 5
a=input() z="" vowels='aeiouAEIOU' for i in range(0,len(a)): if a[i] in vowels and (i+1<len(a) and a[i+1] in vowels): z=a break elif a[i] not in vowels: z+=a[i] print(z) """ further you can reduce if a[i] in vowels : if (i+1<len(a) and a[i+1] in vowels): z=a break else: z+=a[i] #can be done with single loop and #intput() to str convertion not needed """
26th Jan 2022, 3:23 PM
Jayakrishna 🇮🇳
+ 4
tried but getting index out of range error
26th Jan 2022, 12:42 PM
+ 3
use this and understand this . . . word = str((input("Enter a word: "))) print(word, "\n") VOWELS = ("aeiou") newWord ="" for letter in word: if letter.lower() not in VOWELS: newWord += letter print("Your word without vowels is: ",newWord )
26th Jan 2022, 1:08 PM
Davinder Kumar
+ 2
a='Cat' z=[] vowels='aeiouAEIOU' for i in range(0,len(a)): if a[i]==a[i+1]: print(a) else: if a[i] not in vowels: z.append(a[i])
26th Jan 2022, 12:56 PM
+ 1
you can use conditional statement ( if else)
26th Jan 2022, 12:41 PM
Davinder Kumar
+ 1
You can use a loop there, also have many ways.. Try to find a way yourself first And string characters can be extracted by indexes like s="str" print(s[0]) Hope it helps..
26th Jan 2022, 12:43 PM
Jayakrishna 🇮🇳
+ 1
syed fahad show your attempt(save your code in code playground and share it's link here)
26th Jan 2022, 12:43 PM
Rishi
+ 1
yes Jayakrishna is also right you can use loop there..
26th Jan 2022, 12:44 PM
Davinder Kumar
+ 1
#as I+1 is out of range, take a condition as not test a[I+1], this will remove your error like : a='Cat' z=[] vowels='aeiouAEIOU' for i in range(0,len(a)): if i+1<len(a) and a[i]==a[i+1]: print(a) else: if a[i] not in vowels: z.append(a[i]) print(z) #but this is not work as two consecutive vowels.. syed fahad #use (a[I] in vowels and a[I] not in vowels] ), try am not checked now.. you can reply if not work. hope it helps....
26th Jan 2022, 1:09 PM
Jayakrishna 🇮🇳
+ 1
imabhiiiiii🥱 this doesn't work with consecutive vowels
26th Jan 2022, 1:18 PM
+ 1
import string alphabets = list(string.ascii_letters) letters = input('Enter Text: ') all = "" for letter in letters: if letter in alphabets: all += letter print (all)
28th Jan 2022, 2:36 AM
0
can you show me your code ?
26th Jan 2022, 12:43 PM
Davinder Kumar
0
please comment first line of code then print it
26th Jan 2022, 1:22 PM
Davinder Kumar
0
Use Regex instead 1. Search if there are any consecutive vowels more than or equal to 2, then print the string. 2. Else we will search the vowel and replace with empty string in place of vowel. code : import re string = input() if re.search(r'[aeiou]{2, }', string): print(string) elif re.search(r'[aeiou]{1}', string): string = re.sub(r'[aeiou]{1}', '', string) print(string)
27th Jan 2022, 7:52 AM
Rakesh Jinka
0
كيف اكون هكر اخلقي
31st Jan 2022, 9:09 AM
احمد جبر
0
Hi
1st Feb 2022, 2:29 PM
Md Sadin Hasan S