본문 바로가기
Beakjoon&프로그래머스/파이썬

[백준/파이썬] 25813번 Changing Strings

by 현장 2023. 3. 29.

-Code

s = input()

uIndex = s.find("U")
fIndex = s.rfind("F")
res = ""

for i in range(len(s)):
    if i < uIndex or i > fIndex:
        res += "-"
    elif i == uIndex or i == fIndex:
        res += s[i]
    else:
        res += "C"
print(res)