Python 2.7 TypeError: Unsupported operand type(s) for %:'None type' and str

Samuel Harrison

I've got an issue where when i try to print 'filename' i get this error

line 101, in purchase_code_fn
    print("QR Code Created: %s") %(filename)
TypeError: unsupported operand type(s) for %: 'NoneType' and 'str'

Below is the offending function.

def purchase_code_fn():
    count=+1
    name = raw_input("Name: ")
    email_prompt = raw_input("Please enter your email address: ")
    userid = uuid.uuid4()
    filename = (str(email_prompt)+str(count))
    print("QR Code Created: %s") %(filename)
    qr_code_fn(email_prompt, userid)

A pointer in the right direction would be fantastic.

Cheers!

Moses Koledoye

I think you're trying to run Python 2 code with Python 3. In Python 3, print is a function, but a statement in Python 2.

The print function had already been executed and the formatting did not come a priori as you intended or would have in Python 2. So you are trying to format the None returned by print, which is clearly not going to work.

You should remove the closing parenthesis trailing the string:

print("QR Code Created: %s" % filename)  

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Python (TypeError: unsupported operand type(s) for Add: 'undefined' and 'str')

From Dev

TypeError: unsupported operand type(s) for -: 'str' and 'int' Python

From Dev

Python TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'

From Dev

Python (TypeError: unsupported operand type(s) for Add: 'undefined' and 'str')

From Dev

Python 3 TypeError: unsupported operand type(s) for ** or pow(): 'str' and 'int'

From Dev

Python27 TypeError: unsupported operand for type(s) += 'int' and 'str'

From Dev

TypeError: unsupported operand type in Python

From Dev

TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'

From Dev

TypeError: unsupported operand type(s) for |: 'int' and 'str'

From Dev

TypeError: unsupported operand type(s) for +: 'PosixPath' and 'str'

From Dev

TypeError: unsupported operand type(s) for +: 'Tag' and 'str'

From Dev

TypeError: unsupported operand type(s) for +=: 'int' and 'str'

From Dev

Python - Unsupported Operand Type(s) for -: 'int' and 'str'

From Dev

Pandas Groupby : TypeError: unsupported operand type(s) for -: 'str' and 'str'

From Dev

unsupported operand types for //: 'str', 'int'

From Dev

TypeError: unsupported operand type(s) for -: 'str' and 'int' Writing a story?

From Dev

TypeError: unsupported operand type(s) for -: 'str' and 'datetime.datetime'

From Dev

Sum function prob TypeError: unsupported operand type(s) for +: 'int' and 'str'

From Dev

TypeError: unsupported operand type(s) for +: 'int' and 'str' value

From Dev

TypeError: unsupported operand type(s) for -: 'str' and 'numpy.ndarray'

From Dev

TypeError: unsupported operand type(s) for div: 'str' and 'int' [line 14]

From Dev

TypeError: unsupported operand type(s) for /: 'int' and 'str' when making grid

From Dev

Two floats throw TypeError: unsupported operand type(s) for +: 'float' and 'str'

From Dev

TypeError: unsupported operand type(s) for +: 'NoneType' and 'str' / Base conversions

From Dev

Unsupported operand type in Python

From Dev

string substitution in python - unsupported operand type(s) for %: 'list' and 'str'

From Dev

Python re.compile: unsupported operand type(s) for &: str and int

From Dev

python error; unsupported operand type(s) for +: 'int' and 'str'

From Dev

TypeError: Can't convert 'float' object to str implicitly or TypeError: unsupported operand type(s) for -: 'str' and 'float'

Related Related

  1. 1

    Python (TypeError: unsupported operand type(s) for Add: 'undefined' and 'str')

  2. 2

    TypeError: unsupported operand type(s) for -: 'str' and 'int' Python

  3. 3

    Python TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'

  4. 4

    Python (TypeError: unsupported operand type(s) for Add: 'undefined' and 'str')

  5. 5

    Python 3 TypeError: unsupported operand type(s) for ** or pow(): 'str' and 'int'

  6. 6

    Python27 TypeError: unsupported operand for type(s) += 'int' and 'str'

  7. 7

    TypeError: unsupported operand type in Python

  8. 8

    TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'

  9. 9

    TypeError: unsupported operand type(s) for |: 'int' and 'str'

  10. 10

    TypeError: unsupported operand type(s) for +: 'PosixPath' and 'str'

  11. 11

    TypeError: unsupported operand type(s) for +: 'Tag' and 'str'

  12. 12

    TypeError: unsupported operand type(s) for +=: 'int' and 'str'

  13. 13

    Python - Unsupported Operand Type(s) for -: 'int' and 'str'

  14. 14

    Pandas Groupby : TypeError: unsupported operand type(s) for -: 'str' and 'str'

  15. 15

    unsupported operand types for //: 'str', 'int'

  16. 16

    TypeError: unsupported operand type(s) for -: 'str' and 'int' Writing a story?

  17. 17

    TypeError: unsupported operand type(s) for -: 'str' and 'datetime.datetime'

  18. 18

    Sum function prob TypeError: unsupported operand type(s) for +: 'int' and 'str'

  19. 19

    TypeError: unsupported operand type(s) for +: 'int' and 'str' value

  20. 20

    TypeError: unsupported operand type(s) for -: 'str' and 'numpy.ndarray'

  21. 21

    TypeError: unsupported operand type(s) for div: 'str' and 'int' [line 14]

  22. 22

    TypeError: unsupported operand type(s) for /: 'int' and 'str' when making grid

  23. 23

    Two floats throw TypeError: unsupported operand type(s) for +: 'float' and 'str'

  24. 24

    TypeError: unsupported operand type(s) for +: 'NoneType' and 'str' / Base conversions

  25. 25

    Unsupported operand type in Python

  26. 26

    string substitution in python - unsupported operand type(s) for %: 'list' and 'str'

  27. 27

    Python re.compile: unsupported operand type(s) for &: str and int

  28. 28

    python error; unsupported operand type(s) for +: 'int' and 'str'

  29. 29

    TypeError: Can't convert 'float' object to str implicitly or TypeError: unsupported operand type(s) for -: 'str' and 'float'

HotTag

Archive