-2

I need to take user input such as: whacky and 2 and the output needs to be whky

I understand you slice a string with

s[start:stop:skip]

but I am not sure how to achieve my goal.

2
  • 2
    s[:2] + s[-2:] Commented Feb 14, 2021 at 21:27
  • Does this answer your question? Remove char at specific index - python Commented Feb 14, 2021 at 21:28

1 Answer 1

0
s = input()
i = int(input())

print(s[:i] + s[-i:]) 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.