Ada-Developers-Academy / ada-build

Ada Build is curriculum that is intended for anyone who is interested in beginning their journey into coding.
744 stars 419 forks source link

Colaboratory Notebook Problem: Lesson 5 Practice Problems, Reversing a string #296

Open mikaturner opened 1 year ago

mikaturner commented 1 year ago

The colaboratory notebook version of this only has the answer and not the practice problem or test assertions.

This is what is in the notebook version: def reverse_string(input): answer = ""

Your code goes here

for letter in input:
  answer = letter + answer
#  End of your code
return answer

reverse_string("hola")


This is what is in the correct GitHub version:

def reverse_string(input_str): answer = ""

Your code goes here

#  End of your code
return answer

Tests below, do not change

assert reverse_string("hello") == "olleh", "Cannot reverse 'hello'" assert reverse_string("") == "", "When given an empty string it returns an empty string, but doesn't" assert reverse_string("racecar") == "racecar", "Cannot reverse 'racecar'" assert reverse_string("12345") == "54321", "Cannot reverse 12345"

If the program gets here, the code works!

print("Your solution works!")