1

Doing a python problem and trying to create a new string that omits a single char at index n. This works:

newstr = str[:n] + str[n+1:]

but wondering why this didn't work:

newstr = str[:n] + str[-1:-(n+1)]

Thanks in advance^

Avinash Raj
  • 172,303
  • 28
  • 230
  • 274
4life2be
  • 11
  • 3
  • Your slice limits are inverted. – Prune Jun 12 '21 at 00:37
  • 2
    For future posts, please provide the expected [MRE - Minimal, Reproducible Example](https://stackoverflow.com/help/minimal-reproducible-example). "didnt' work" is not a problem specification, and your posted code doesn't run. – Prune Jun 12 '21 at 00:37

0 Answers0