Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Is it possible to create an error in the input class, or what is the difference between str and input?

If I try to place the following value : "' as text when by putting it in brackets as follows: a = str(""'"), it will give the following error:

SyntaxError: EOL while scanning string literal

On the other hand if I enter "' as an input it will accept it by default as a string.

How does the input class manage to convert it to string?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

And is there any sequence of keys that will cause the input class to get an error when receiving a value and converts it to string?

>Solution :

When you want both quote marks: " and ' inside a literal string, you can either add them separately or you can use so-called triple-quotes to surround them:

a = '''""' '''  # note the trailing space
b = """ ""'"""  # note the leading space
print(a)
print(b)

This may not be what you want.

Alternatively:

double = '"'
single = "'"
a = double + single
print(a)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading