1 2 3 4 5 6 7 8 9 | s = "Hello, WORLD. KOREA" s_idx = 7 # ¼Ò¹®ÀÚ º¯°æ ½ÃÀÛ index e_idx =12 # ¼Ò¹®ÀÚ º¯°æ Á¾·á index t = s[s_idx:e_idx] t= t.lower() s_modify = s[:s_idx] + t + s[e_idx:] print(s_modify) | cs |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | s = "Hello, WORLD. KOREA" s_idx = 7 # ¼Ò¹®ÀÚ º¯°æ ½ÃÀÛ index e_idx =12 # ¼Ò¹®ÀÚ º¯°æ Á¾·á index s_modify ="" for i,c in enumerate(s): if i>=s_idx and i<e_idx : s_modify += c.lower() else: s_modify += c print(s_modify) | cs |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | s = "Hello, WORLD. KOREA" s_idx = 7 # ¼Ò¹®ÀÚ º¯°æ ½ÃÀÛ index e_idx =12 # ¼Ò¹®ÀÚ º¯°æ Á¾·á index s_modify ="" i = 0 for c in list(s) : if i>=s_idx and i<e_idx : s_modify += c.lower() else: s_modify += c i += 1 print(s_modify) | cs |