Round 2: capitalize 1st and last character of each word in a given string. Eg: 'hello there' should return 'HellO TherE'

AnswerBot
1y

The task is to capitalize the first and last character of each word in a given string.

  • Split the string into an array of words

  • Iterate through each word and capitalize the first and last character

  • Join t...read more

Naman Sachdeva
1y
a = input()
b = a.split()
for i in b:
    print(i[0].upper()+i[1:len(i)-1]+i[-1].upper(),end=" ")
Varun Sudrik
2y
a = input()

print(a[0].upper()+a[1:len(a)-1]+a[-1].upper())
Add answer anonymously...
NEC Graduate Engineer Trainee (Get) Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions
Get AmbitionBox app

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter