user9668155
user9668155

Reputation: 1

Python - Quotation Marks as Variables

Is it possible to use quotation marks as a variable?

a = input("Insert Here")
If a is " " ":
       Do something

Also, would I have to do = or Is?

Upvotes: 0

Views: 68

Answers (2)

cdarke
cdarke

Reputation: 44394

If you have double quotes inside a string literal then use single quotes, or escape it.

Don't use is unless you want to see if two references refer to the same object. To test equality use ==, a single = is an assignment:

a = input("Insert Here: ")
if a == '"':
   Do something

Upvotes: 1

daveoncode
daveoncode

Reputation: 19618

you have two options:

  1. Wrapping with single quotes: '"'
  2. Escaping with backslash: "\""

Upvotes: 0

Related Questions