• Register
1 vote

Problem :

The program supposed to take in two names, and if they are the same length it should check if they are the same word.

But i am getting below error in python

python typeerror: not all arguments converted during string formatting

6 5 3
6,930 points

2 Answers

1 vote


The correct way to use traditional string formatting using the '%' operator is to use a printf-style format string (Python documentation for this here: http://docs.python.org/2/library/string.html#format-string-syntax):

Further Readings:


9 7 4
38,600 points
1 vote


If I understand correctly, you are having the String formatting issue. Correct me if I am wrong. It is hard to get the problem and provide a solution without seeing the code snippet. Please attach the code snippet with your question from your next post. As per my understanding, the right way formatting a string in python3 is:

print("Hello {}, your balance is {}.".format("Adam", 230.2346))

And as long as the whole program is concerned you don’t need to use string formatting in your codes. You can try this:

first_name = input("\nEnter the frist name")
second_name = input("\nEnter the second name")
if len(first_name) == len(second_name):
	if first_name == second_name:
		print("\nSame name")
		print("Not the same name")

Good luck!

13 9 6
94,240 points

Related questions

0 votes
1 answer 1.5K views
Problem : I am facing the issue in passing a function as a parameter to another function as follows typeerror: int() argument must be a string, a bytes-like object or a number, not 'nonetype'
asked Nov 18, 2019 peterlaw 6.9k points
0 votes
1 answer 9 views
On making a small program for math there returned an error "TypeError: 'NoneType' object is not subscriptable. Never before has been seen, this error, so no idea what it means. import math print("The format you should consider:") print str("value 1a")+str(" + ")+ ... /Nathan/Documents/Python/New thing", line 16, in <module> a = lista[1] - lista[0] TypeError: 'NoneType' object is not subscriptable
asked 8 hours ago psandprop 640 points
1 vote
1 answer 56 views
Problem: I wrote a program in which gives me the following error : TypeError: startswith first arg must be bytes or a tuple of bytes, not str The program I wrote is: def allFasta(filename): xd = open(filename, 'yb') headers = "" sequence = "" while True: ... ("youn.xd") Why is this type error message is appearing for this program. Is there any problem with my programs arguments? Thanks in advance.
asked Jun 11 samhaz 5k points
0 votes
2 answers 938 views
Problem : I am new to Py 3.5. This code was working properly in Python 2.7: with open(fname, 'rb') as f: lines = [x.strip() for x in f.readlines()] for line in lines: tmp = line.strip().lower() if 'some-pattern' in tmp: continue # ... code After upgrading to 3.5, I'm getting the: TypeError: a bytes-like object is required, not 'str'
asked Oct 22, 2019 peterlaw 6.9k points