• Register
1 vote
46 views

Problem :

I have recently started learning Python 3. I am beginner to the programming world. Please find below the code responsible for the error:

a = "I know the %d types of people." % 10
Integer = "integer"
do_not = "don't"
b = "Those type of people who know %s and those who %s" % (Integer, do_not)
print(a)
print(b)
print("I know: %r") % a
Is there any difference between the %r%s and %d ?

I am often facing below error:

Typeerror: unsupported operand type(s) for %: 'nonetype' and 'tuple'”.

Kindly guide me in fixing my above error?

8 5 2
3,230 points

1 Answer

1 vote

Solution :

I know I can help you in fixing above mentioned error. I guess you want to call your % outside of your print() function. Your function is trying to cross check if your actual function print is printed as %r and as your print is not returning anything so now it is trying to get the %r for your value None this is the main reason behind your NoneType error.

So you need to change it to:

print("I said: %r" %(a))

If you make changes to your code like the code below then it will work for you:

a = "Hello"
print ("Hello People! %s" %(a))

I hope it helps you.

8 4
5,680 points

Related questions

1 vote
1 answer 49 views
49 views
Problem: I wrote the following program in python and it throws me the error message: Please enter your first number: 10 Please enter your secoend number: 5 Addition of your numbers 105 Traceback (most recent call last): File "ires.py", line 9, in <module> ... some wong output and then it throws the error message. Is there any problem in my program thats causing this error? Thanks in advance.
asked May 12 samhaz 5k points
1 vote
1 answer 26 views
26 views
Problem: For the following python program et some error messages. The code: def Yanwa(Array,a): n = len(Array) for column in xrange(n-1): for row in xrange(column+1, n): xmult = Array[row][column] / Array[column][column] Array[row][column] = xmult for col in ... not defined Typeerror: unsupported operand type(s) for -: 'list' and 'list' Can any one sort this problem and help me out to solve this?
asked Apr 27 samhaz 5k points
1 vote
1 answer 56 views
56 views
Problem : I am a student and I am trying to learn python. I like programming so trying my hand on Python but the code which I have written in Python is giving me very strange looking error shown as below for your reference. Error: unsupported operand type(s) for ... array1=[1,2,3,4,5]; encryptedArray=runEncrypt(array1,4); print(encryptedArray); Please guide me in fixing my above error in Python.
asked May 15 Martin K 6.6k points
1 vote
1 answer 227 views
227 views
Problem: I have been working on project. For that I wrote the code: def For_me(Array,a): n = len(Array) for column in xrange(n-1): for row in xrange(column+1, n): xmult = Array[row][column] / Array[column][column] Array[row][column] = xmult for col in xrange( ... [7]]) But it gives me error message: TypeError: unsupported operand type(s) for -: 'list' and 'list' Can anyone help me otto solve this?
asked Apr 5 LizzyM 6.1k points
1 vote
1 answer 103 views
103 views
Problem: Hi all This is a question from a noob who started coding a few hours back. print("Hello") print("name") print("hello") print("Let's do some math!") print(5 + "a") print("5 + 5") print("Thanks for playing along!") It says, &ldquo;typeerror: unsupported operand type(s) for +: 'int' and 'str'&rdquo; What does it mean?
asked Mar 9 Gavin 15.3k points