• Register
1 vote
66 views

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.9k points

2 Answers

1 vote

Solution:

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:

https://github.com/getpelican/pelican/issues/2489

36.1k points
edited by
1 vote

Solution:

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")
	else:
		print("Not the same name")

Good luck!

94.2k points

Related questions

0 votes
1 answer 1.2K views
1.2K 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
2 answers 810 views
810 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
1 vote
1 answer 23 views
23 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
1 vote
1 answer 23 views
23 views
Problem : I want to learn the python programming and also want to work on projects. One of my projects is to code the voting system so that it can select the best player among 23 players of a match by using the lists. I am currently using the Python3. Please ... any of the strings in my above code all my variables are of the type integers. Please guide me in fixing above python related error.
asked May 14 Martin K 6.6k points
0 votes
1 answer 163 views
163 views
Problem : When I try to run following command: python manage.py updatestats I get the error as below: “TypeError: int() argument must be a string, a bytes-like object or a number, not 'list'” I am unable to figure out ... ) File "/Users/alecxe/project/Dev/project_files/project/main/management/commands/updatestats.py", line 34, in handle unique_visits=display_unique_visits(hostname),)
asked Jan 2 alecxe 7.5k points