+ 4

Accepting the string that completely has vowels

I have a case where it should output as "Accepted" if the string input given by the user has completely vowels else "Not Accepted" In my case I coded in 2 ways 1st way=> https://code.sololearn.com/cWcxKi0b8234/?ref=app 2nd way=> https://code.sololearn.com/crhy7hlS3z73/?ref=app 2nd approach was failing for 1 case (which was hidden so I couldn't come to the conclusion about the fault) 1st approach passed all cases What is the difference do that if condition is making in 1st approach? Example: Input 1 aeiou Output Accepted -------------------------| Input 2 Qerufjdzk Output Not Accepted

20th May 2021, 5:34 PM
Nivya
Nivya - avatar
26 Antworten
+ 4
Nivya try The input 'aaaaaaa' is not accepted by 1st one. In 2nd, it is accepted. You are using && operator in 1st code in if condition and in 2nd code you are using || operator..
20th May 2021, 6:12 PM
Jayakrishna 🇮🇳
+ 3
Jayakrishna🇮🇳 OP said that first code pass all tests... so I guess its logic is fine, don't you think?
20th May 2021, 6:39 PM
visph
visph - avatar
+ 2
I think you lack of curly brackets in the second one ^^ try by enclosing your inner if..else body parts... and say if that pass the tests ;)
20th May 2021, 5:54 PM
visph
visph - avatar
+ 2
The 1st approach need input all vowels atleast ones but 2nd ones needs vowels all ,not necessarily all 5.... Is that intention differential?
20th May 2021, 6:05 PM
Jayakrishna 🇮🇳
+ 2
correctly indented you may better see what I mean: https://code.sololearn.com/cr1E56jMeEpD/?ref=app
20th May 2021, 6:06 PM
visph
visph - avatar
+ 1
Jayakrishna🇮🇳 In both approaches entire string should be vowel only then it should accept it But I'm not getting what is the difference between these 2 codes with that if cOndition
20th May 2021, 6:08 PM
Nivya
Nivya - avatar
+ 1
your continue and break may not behave as you think ^^
20th May 2021, 6:09 PM
visph
visph - avatar
+ 1
Jayakrishna🇮🇳 Woooh!! now it's against my assumption lol,now what is right :( , though the first approach is false for this 'aaaaa' it passed since that case wasn't there may be .... what about the second which was the hidden case Where is wrong
20th May 2021, 6:15 PM
Nivya
Nivya - avatar
+ 1
in short: continue and break are always executed...
20th May 2021, 6:17 PM
visph
visph - avatar
+ 1
Depends on actual question.. is it need all vowels atleast ones or any number of times?
20th May 2021, 6:18 PM
Jayakrishna 🇮🇳
+ 1
but in last code your break occur after the first letter... because it is not part of the else body ^^
20th May 2021, 6:24 PM
visph
visph - avatar
+ 1
Nivya Input : ' aaaaa ' has all vowels. (no consonents) Input : ' aeiou ' has all vowels.. I think the question is about 'input should contain 'aeiou' all ( atleast ones)
20th May 2021, 6:27 PM
Jayakrishna 🇮🇳
+ 1
Jayakrishna🇮🇳 Given a string, the task is to check and accept the given string if contains all vowels i.e. ‘a’, ‘e’, ‘i’.’o’, ‘u’ or ‘A’, ‘E’, ‘I’, ‘O’, ‘U’ . >>Input Format Input a string >>Constraints String consists of alphabet >>Output Format Check whether the input string has all vowels in it or not Sample Input 0 aeiou Sample Output 0 Accepted Sample Input 1 aeigh Sample Output 1 Not Accepted >>>>This is the problem statement they haven't mentioned it so like that
20th May 2021, 6:30 PM
Nivya
Nivya - avatar
+ 1
Jayakrishna🇮🇳 according to 1st code yes that is where the difference is ...I took question as all vowels not particularly aeiou (atleast once)...thank you so much for the clarification!!
20th May 2021, 6:36 PM
Nivya
Nivya - avatar
+ 1
I think it needs to check input has 'aeiou' all 5 vowels or not. (May it also contains others alphabets, it is not clear there.) edit: Nivya check input ' aeiouzz ' is accepted by 1st but not by 2nd. so it clear 'need to check all 'aeiou' are in input or not
20th May 2021, 6:36 PM
Jayakrishna 🇮🇳
+ 1
Nivya Input : ' aaaaa ' has all vowels. (no consonents) Input : ' aeiou ' has all vowels.. I think the question is about 'input should contain 'aeiou' all ( atleast ones) Jayakrishna🇮🇳 I feel what you said here hold good for this code but they didn't mention that properly so, the second code is going wrong
20th May 2021, 6:39 PM
Nivya
Nivya - avatar
+ 1
Jayakrishna🇮🇳 yes I got it !! That's the problem statement!! Thanks a load:)))
20th May 2021, 6:42 PM
Nivya
Nivya - avatar
+ 1
visph yeah the logic is fine with both in different view,but what we actually need is as Jayakrishna🇮🇳 mentioned sample inputs, like that and those are the conditions....
20th May 2021, 6:44 PM
Nivya
Nivya - avatar
+ 1
Jayakrishna🇮🇳 almost: I didn't have noticed the && difference (but I had upvoted your post talking about it)... I was only guessing that maybe it was a problem of lack of curly brackets, but I was wrong ;P
20th May 2021, 6:51 PM
visph
visph - avatar
+ 1
vowels = ["a", "e", "i", "o", "u"] string = input("Enter the string: ").lower() s = set() print(string) for vowel in string: if vowel not in vowels: print("NOT ACCEPTED") break else: print("ACCEPTED")
21st Oct 2021, 12:52 PM
uday kumar A B
uday kumar A B - avatar