## DEV Community is a community of 620,623 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

# Discussion on: Daily Challenge #124 - Middle Me Gabriel Romualdo • Edited

My solution in Python:

``````def middle_me(x, y, n):
if(n % 2 != 0):
return x
else:
return ( y * (n / 2) ) + x + ( y * (n / 2) )
``````

Which can be abbreviated to:

``````def middle_me(x, y, n):
return x if n % 2 != 0 else ( y * (n / 2) ) + x + ( y * (n / 2) )
``````

Hoped you liked this solution, definitely not the most efficient or clean, but I have been working on my Python skills as I am mainly a web developer working with JS and ES6.

— Gabriel Rafael Acioly

Nice! just a hint, if you have a `return` inside the first `if` you don't need the `else` ;)

Here's my solution:

``````def middle_me(middle: str, repeat: str, repeat_quantity: int) -> str:
if repeat_quantity % 2 != 0:
return middle

half = repeat_quantity // 2
content = repeat * repeat_quantity
return content[:half] + middle + content[half:]
``````