Hi! Why it not work?! =( str = 'abc def ghi' return str.title()
@wrttech422 Жыл бұрын
str is a keyword, and you cant use it as the name of a variable. Instead, write it like below (or something similar) strr = 'abc def ghi' return strr.title() im assuming there is more to this code as well? Since you are using a return statement, it must exist within a function.
@АндрейНИКАНОВ-у1м Жыл бұрын
@@wrttech422 Task: Create a function called shortcut to remove the lowercase vowels (a, e, i, o, u ) in a given string (8kyu). I have 12 passed and 3 fails. "hello" --> "hll" "codewars" --> "cdwrs" "goodbye" --> "gdby" "HELLO" --> "HELLO" def shortcut( s ): s2 = 'a,e,i,o,u' s3 = "" for x in s: if x not in s2 or x.isupper(): s3 += x return s3
@wrttech422 Жыл бұрын
The code below works. The problem you had was with the string s2 = "a,e,i,o,u". Reason being is bc you're using that string to remove the lowercase vowels from string s; however, string s2 contains 4 commas which will also be removed from string s. Unlike lists, strings do not require commas as separators. Copy and paste the code below def shortcut( s ): s2 = 'aeiou' s3 = "" for x in s: if x not in s2: s3 += x return s3
@wrttech422 Жыл бұрын
You could also do it in one line of code like below: def shortcut( s ): return ''.join([i for i in s if i not in 'aeiou'])