Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unsupported operand type(s) for %: 'NoneType' and 'tuple'

Tags:

python

I am getting this error:

TypeError: unsupported operand type(s) for %: 'NoneType' and 'tuple'

What do I need to change to fix this?

string_1 = "Sean";
string_2 = "beginner programmer";

print("Hi my name is %s, I\'m a %s.") % (string_1,string_2);
like image 549
Seannn lim Avatar asked Oct 17 '16 17:10

Seannn lim


People also ask

How do you fix unsupported operand type S for NoneType and int?

Unsupported operand type(s) for +: 'NoneType' and 'int' # The Python "TypeError: unsupported operand type(s) for +: 'NoneType' and 'int'" occurs when we try to use the addition (+) operator with a None value. To solve the error, figure out where the variable got assigned a None value and correct the assignment.

How do you fix unsupported operand types?

The Python "TypeError: unsupported operand type(s) for /: 'str' and 'int'" occurs when we try to use the division / operator with a string and a number. To solve the error, convert the string to an int or a float , e.g. int(my_str) / my_num .

How do you fix unsupported operand type S for STR and STR?

The Python "TypeError: unsupported operand type(s) for -: 'str' and 'str'" occurs when we try to use the subtraction - operator with two strings. To solve the error, convert the strings to int or float values, e.g. int(my_str_1) - int(my_str_2) .

What does unsupported operand type S for +: int and list?

The Python "TypeError: unsupported operand type(s) for +: 'int' and 'list'" occurs when we try to use the addition (+) operator with a number and a list. To solve the error, figure out where the variable got assigned a list and correct the assignment, or access a specific value in the list.


1 Answers

print returns None, you must format the string before printing it

print("Hi my name is %s, I\'m a %s." % (string_1, string_2))
like image 78
Francisco Avatar answered Sep 28 '22 17:09

Francisco