Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2017
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. def enter_sentence():
  2. sentence = raw_input("Please enter a long sentence : ")
  3. string = sentence.replace(" ","")
  4. print "Last Character in the sentence :",string[-1:]
  5. print "Last 5 Characters in the sentence :",string[-5:]
  6. print "Character at 2nd and 5th positions are :"+string[1],string[4]
  7. center = int(len(string))/2
  8. end = center+1
  9. print "Character at the center of the string ,along with 2 adjoining characters is : ",string[center-2:end]
  10.  
  11. # Main starts from here
  12. if __name__ == "__main__":
  13. print "Let's start"
  14. enter_sentence()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement