python – How to convert certain elements of a string to uppercase?

Question:

You need to take every second character in the string and convert it to upper case.

Example:
Input: future
Conclusion: FuTuRe

This is how I get and output every second character:

a = 'future'
b = a[::2]
print(b)

How to output other characters along with them?

Answer:

Another short solution:

"".join([x.upper() + y for x,y in zip(a[::2], a[1::2])])
>>> 'FuTuRe'
Scroll to Top