Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Creative or Convoluted? solution in Creative category for Backward String by BootzenKatzen
#I definitely did this the hard way. I forgot that we could use slicing to just return the whole thing backwards.
#Whoops.
def backward_string(val: str) -> str:
newstring = ""
valnew = val
while valnew != "":
newstring += valnew[-1]
try:
valnew = valnew[:-1]
except:
valnew = ""
return newstring
print("Example:")
print(backward_string("val"))
# These "asserts" are used for self-checking
assert backward_string("val") == "lav"
assert backward_string("") == ""
assert backward_string("ohho") == "ohho"
assert backward_string("123456789") == "987654321"
print("The mission is done! Click 'Check Solution' to earn rewards!")
March 29, 2023
Comments: