+ 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
26 odpowiedzi
+ 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..
+ 3
Jayakrishna🇮🇳 OP said that first code pass all tests... so I guess its logic is fine, don't you think?
+ 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 ;)
+ 2
The 1st approach need input all vowels atleast ones but 2nd ones needs vowels all ,not necessarily all 5....
Is that intention differential?
+ 2
correctly indented you may better see what I mean:
https://code.sololearn.com/cr1E56jMeEpD/?ref=app
+ 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
+ 1
your continue and break may not behave as you think ^^
+ 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
+ 1
in short: continue and break are always executed...
+ 1
Depends on actual question.. is it need all vowels atleast ones or any number of times?
+ 1
but in last code your break occur after the first letter... because it is not part of the else body ^^
+ 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)
+ 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
+ 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!!
+ 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
+ 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
+ 1
Jayakrishna🇮🇳 yes I got it !!
That's the problem statement!!
Thanks a load:)))
+ 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....
+ 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
+ 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")