+ 5

I have a problem!

I have written my problem in the code please check that 👇 Thanks https://code.sololearn.com/c9O4nu5AU8v8/?ref=app

18th Apr 2018, 2:53 AM
The Coder
The Coder - avatar
17 Respuestas
+ 8
Here's an example of using the difflib SequenceMatcher.ratio() method. I arbitrarily picked .7 as a cutoff ratio but you can experiment with different numbers. At this cutoff, "hellish fiends" is similar enough to "hello friends" to pass but "hollow frogs" fails. https://code.sololearn.com/cV0IY8wfD38A/?ref=app
18th Apr 2018, 6:24 AM
David Ashton
David Ashton - avatar
+ 12
You miss the print statement within the else statement. a = input() if a == "hello friends": print("Hi") else : print("You are not allowed") Also, if you plan to fulfill the problem statement, I suggest using regex.
18th Apr 2018, 2:58 AM
Hatsy Rei
Hatsy Rei - avatar
+ 8
I am a bit happy that hollow frogs dont match.... (-:
18th Apr 2018, 6:29 AM
Oma Falk
Oma Falk - avatar
+ 7
1. set input to lower case 2. check if input contains hello 3. check if input contains friend 4. check if len(input) is round about 13 5. split input to check borh words seperately. 6. check if set of input and set of hello friend are similiar (intersection)....
18th Apr 2018, 6:22 AM
Oma Falk
Oma Falk - avatar
+ 7
Xan also thanks from me!
18th Apr 2018, 6:45 AM
Oma Falk
Oma Falk - avatar
+ 6
Oma Falk True, but fiends are still pretty creepy 👹
18th Apr 2018, 6:30 AM
David Ashton
David Ashton - avatar
+ 6
Xan Thanks for sharing the cool module!
18th Apr 2018, 6:44 AM
David Ashton
David Ashton - avatar
+ 6
Xan your old boss must be a amazing person!
18th Apr 2018, 12:48 PM
The Coder
The Coder - avatar
+ 5
Ace and Hatsy Rei Thanks I will check it out!
18th Apr 2018, 3:04 AM
The Coder
The Coder - avatar
+ 4
Ace I wanted to say that if the string doesn't match completely but nearly the same so it perform the function Thanks
18th Apr 2018, 3:02 AM
The Coder
The Coder - avatar
+ 4
Ace, Hatsy Rei, Xan , David Ashton I'm unable to understand Regex and sequence match in internet please provide me a example code so that I can have an Idea Thanks
18th Apr 2018, 5:49 AM
The Coder
The Coder - avatar
+ 3
With PCRE regex flavor, you'd write sth as below to match it. (h|H)ello (f|F)riend(s)? Will accept, Hello friends hello friend hello Friend ...
18th Apr 2018, 10:39 AM
Babak
Babak - avatar
+ 3
Sample cpp code for that pattern [https://code.sololearn.com/c3J89K2Ie3N2/?ref=app]
18th Apr 2018, 10:59 AM
Babak
Babak - avatar
0
No problem. I didn't know about it either, until I did some digging after reading your question. My old boss used to say: "It's highly likely somebody has solved a problem before" also "If something is too difficult, then you just haven't found an easier solution yet". Quite obvious, I know. However, if I remember those two ideas, I often get to a better solution.
18th Apr 2018, 11:06 AM
Emma