N = 2
str1 = "abcdefg"
str2 = str1[:-N]
print(str2)

結果

abcde