x = 2
y = 5
str1 = "abcdefg"
str2 = str1[x:y]
print(str2)

結果

cde