id/email
password
forgot password | create account
about | help | prefs
ReadingBatcode reading practice

 

 

Warmup 1replace4

prev  |  next  |  chance
def replace4(x):
    if len(x) <= 1:
        return x
    if x[0] == x[len(x) - 1]:
        return x[0] + x
    return x + x[len(x) - 1]
Function Call  Return Value
replace4('hello')
replace4('aba')
replace4(' world')
replace4('')
replace4('goodbye')
replace4('oof')
replace4('a')

Experiment with this code on Gitpod.io

⬅ Back