A=input()
new=ββ
if A[0]!=βsβ and A[0]!=βiβ and A[0]!=βoβ:
new=new+A[0].upper()
for i in range(len(A)):
if A[i]==βsβ:
new=new+β$β
elif A[i]==βiβ:
new=new+β!β
elif A[i]==βoβ:
new=new+β()β
else:
new=new+A[i]
new=new+β.β
print(new)
A=input()
if A[0]!=βsβ and A[0]!=βiβ and A[0]!=βoβ:
A=A.replace(A[0], A[0].upper())
A=A.replace(βsβ,β$β)
A=A.replace(βiβ,β!β)
A=A.replace(βoβ,β()β)
A=A+β.β
print(A)
I think you got wrong hoe the replace() function works.
Try different ways of capitalizing the 1st character.
Itβs showing WA cause it is producing WA.
for inputs like aba, your code will capitalize every a word and will show AbA.
What is the problem with this code ?
I ran more than 20 words and it perfectly show me the expected answer on my IDE.
**** Python *****
word = []
a = input().lower()
if len(a) < 16:
for x in a:
if x == 's':
x = '$'
if x == 'i':
x = '!'
if x == 'o':
x = '()'
word.append(x)
if word[0] == '$':
word[0] = 's'
if word[0] == '!':
word[0] = 'i'
if word[0] == '()':
word[0] = 'o'
for y in word:
if y == word[0]:
print(word[0].upper(), end='')
else:
print(y, end='')
s = str(input())
if len(s) < 16:
u = s.replace(s[:1], s[:1].upper())
u = u.replace('s', '$')
u = u.replace('i', '!')
u = u.replace('o', '()')
print(u + '.')
This gets the βwrong answerβ in the 5th test case. I donβt know whatβs wrong
with it.
@Aurjon the replace function doesnβt work this way. It takes a string and replaces it with another string. This, just change the first character separately.
A = input()
li1 = ('s', 'i', 'o')
li2 = ('$', '!', '()')
for i in A:
if i == A[0]:
A = A.replace(i, i.upper())
elif i == li1[0]:
A = A.replace(i, li2[0])
elif i == li1[1]:
A = A.replace(i, li2[1])
elif i == li1[2]:
A = A.replace(i, li2[2])
if '.' in A:
output = f"{A}"
else:
output = f"{A}."
print(output)`Preformatted text`
@touhidurrr
Can you please help me out,how can I replace o with (),because each time I am having wrong answer and it only replace β(β this character