I tried adding only the if condition but getting error. Anyone can help pls.
Your code so far
# User Editable Region
def caesar(text, shift):
if not isinstance(shift, int):
return 'Shift must be an integer value.'
if (shift<1):
return 'Shift must be a positive integer.'
# User Editable Region
alphabet = 'abcdefghijklmnopqrstuvwxyz'
shifted_alphabet = alphabet[shift:] + alphabet[:shift]
translation_table = str.maketrans(alphabet + alphabet.upper(), shifted_alphabet + shifted_alphabet.upper())
return text.translate(translation_table)
encrypted_text = caesar('freeCodeCamp', 3)
print(encrypted_text)
Your browser information:
User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36
What are the test saying to you exactly ? If it is something like “Your code raised an error before testing. Please try again.”, it is because there is an error in your code that stops the Python from running (ex : SyntaxError, IndentationError, etc).
In the future, please create your own topic when you have specific questions about your own challenge code. Only respond to another thread when you want to provide help to the original poster of the other thread or have follow up questions concerning other replies given to the original poster.
The easiest way to create a topic for help with your own solution is to click the Ask for Help button located on each challenge. This will automatically import your code in a readable format and pull in the challenge url while still allowing you to ask any question about the challenge or your code.