Skip to main content
Practice

coding-quiz-2

---
id: coding-quiz-2
title: Coding Quiz - String Case Conversion
description: Write a function that converts characters at even indices to uppercase and characters at odd indices to lowercase
tags:
- Coding Quiz
- Case Conversion
- String
- Python
sidebar_position: 6
isPublic: false
---

# Coding Quiz - String Case Conversion

In this coding quiz, you'll write a function that converts characters in a given string to uppercase at even indices and to lowercase at odd indices.

For example, if the input string is `codefriends`, the output should be `cOdEfRiEnDs`.

<br />

```python title="Write Your Code"
def solution(s):
# Write your code here
return



Constraints

  • The length of the input string is between 1 and 100.

  • The string contains only alphabetic letters.




Example Input/Output

  • Input: codefriends

  • Output: cOdEfRiEnDs


  • Input: CoDe

  • Output: cOdE

Want to learn more?

Join CodeFriends Plus membership or enroll in a course to start your journey.