-1

as title says i simply need to add a . before each letter in my string while having vowels removed and making it lowercase i got it working just cant add the .s there here is my code

s = str(input())
vowels = ('a','e','o','u','i','A','E','O','U','I')
for letter in s:
    if letter in vowels:
        s = s.replace(letter,'').replace()
print(s)
Willem Van Onsem
  • 443,496
  • 30
  • 428
  • 555
KaZ
  • 1
  • 2

3 Answers3

8

Use:

s = input()
vowels = set('aeoui')

print(''.join([f'.{x}' for x in s.lower() if x not in vowels]))

Sample run:

Hello
.h.l.l
Austin
  • 25,759
  • 4
  • 25
  • 48
1

All other answers will insert a . in front of every character in the string, but you specified that you want letters only. So I am assuming that you only want a-z to be prepended with a . for which I suggest re.sub:

import re
s = "This is some test string. It contains some symbols also ()!!"
result = re.sub('[aeoui]', '', s.lower())  # remove vowels and make lowercase
result = re.sub("([a-z])", r".\1", result)  # prepend '.' to every letter
print(result)

Outputs:

.t.h.s .s .s.m .t.s.t .s.t.r.n.g. .t .c.n.t.n.s .s.m .s.y.m.b.l.s .l.s ()!!
FlyingTeller
  • 17,638
  • 3
  • 38
  • 53
-1

You can do it step by step:

Replace all the vowels in the string with ''

for i in s:
    for j in vowels:
        s=s.replace(j,'')

Convert the string into lowercase:

s=s.lower()

Adding '.' in between each letters:

s='.' + '.'.join(s)
RemyM
  • 168
  • 1
  • 8