1

Let's say I'm making a cat program, where I intend to take the user's input using input(), store it as a string for later use, then output the string (for simplicity, let's say it just prints it).

Is there anything the user could input that would make my program not store the string properly? I have tested special characters like \n but they work fine - are there any very obscure characters that could break my program somehow?

Here is a heavily simplified version of my code that should behave the same way as my non-simplified code:

a = input()
print(a)
2
  • The only thing I could think as a potential issue is \0 (NULL) Commented Jun 30, 2020 at 18:38
  • @jordanm I don't think Python stores strings as C strings, so null is not a problem. Commented Jun 30, 2020 at 18:41

1 Answer 1

3

There is no possible way to break the code with input, the input function only stores what the user says. It doesn't matter whether you input a string, unicode, or anything else the result will always be the same. However if the variable is given power like in the following example:

import os

a = input()
os.system(a)

then the variable can access the command line. If you do not write in access to a shell there is nothing the variable can do.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.