File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change
1
+
2
+ def anagram (input1 , input2 ):
3
+ input1 = input1 .replace (" " ,"" ).lower ()
4
+ input2 = input2 .replace (" " ,"" ).lower ()
5
+ if sorted (input1 ) == sorted (input2 ):
6
+ return True
7
+ else :
8
+ return False
9
+
10
+
11
+ print (anagram ("rat" , "art" ))
12
+ print (anagram ("alert" , "alter" ))
13
+ print (anagram ("Slot machines" , "Cash lost in me" ))
Original file line number Diff line number Diff line change
1
+ # Reverse the words in sentence
2
+ def word_flipper (our_string ):
3
+ inputList = our_string .split (" " )
4
+ reverseList = []
5
+ for word in inputList :
6
+ reverse = ""
7
+ for i in range (0 , len (word )):
8
+ reverse += word [len (word )- 1 - i ]
9
+ reverseList .append (reverse )
10
+ reverseString = " " .join (reverseList )
11
+ return reverseString
12
+ # print(word_flipper("This is one small step for ..."))
13
+ print ("Pass" if ('retaw' == word_flipper ('water' )) else "Fail" )
14
+ print ("Pass" if ('sihT si na elpmaxe' == word_flipper ('This is an example' )) else "Fail" )
15
+ print ("Pass" if ('sihT si eno llams pets rof ...' == word_flipper ('This is one small step for ...' )) else "Fail" )
You can’t perform that action at this time.
0 commit comments