s.replace() calls having no effect in Python -


s = input() s.lower() in range (0, len(s)):     if(s[i] in "aoyeui"):         s.replace(s[i], '') in range(0, len(s)):     s.replace(s[i], '.' + s[i]) print(s)  

this code should remove vowels , split string '.'

lets comment line line:

    s = input ()  #wrong indentation s.lower()      #  have assign s.  in range (0, len(s)):  # range(0, x) same range(x)     if (s[i] in "aoyeui"): #  ok          s.replace(s[i], '')  # strings not mutable replace not modify string. have assign s # splitting can done easier :) in range(0, len(s)):       s.replace(s[i], '.' + s[i])  # again have assign print(s)  # ok 

also have noticed there 1 more problem code. when replace vowels string length changes , can cause multiple problems. should not in general iterate index when length changes. correct code should like:

s = input () s = s.lower() vowel in "aoyeui":         s = s.replace(vowel, '') s = '.'.join(list(s))  # how separate each character dot (much easier eh?) print(s) 

Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -