-5

I want to enter a word from keyboard, put it in a string variable and return first and last letter from the word. But I don't know to to do this.

input: "Hello"
output: "H", "o"

P.S: I want to put this 2 letters in a variable:

print(first)
output:"H"
print(last)
output:"o"

Please give me a solution!

Mikey
  • 29
  • 2
  • 2
  • 4

1 Answers1

11

simply.

st = "hello"
print st[0] #first char
print st[-1] #last char
arundeepak
  • 564
  • 2
  • 12