• Register
1 vote
100 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 5 3
6,930 points

Please log in or register to answer this question.

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

9 7 4
38,600 points
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!

13 9 6
94,240 points

Related questions

0 votes
1 answer 7 views
7 views
Problem: One of the main features of the Java language keeps you in check so that your programs work in the way that you intend. You may encounter an error saying “not all arguments converted during string formatting” How i working with strings.
asked Dec 2, 2020 Mashhoodch 6.7k points
0 votes
1 answer 20 views
0 votes
1 answer 1.9K views
1.9K 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 18 views
18 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 Oct 24, 2020 psandprop 2.4k points
1 vote
1 answer 66 views
66 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, 2020 Martin K 6.6k points
1 vote
1 answer 319 views
319 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, 2020 samhaz 5k points
0 votes
1 answer 246 views
246 views
Problem : When I try to run following command: python manage.py updatestats I get the error as below: &ldquo;TypeError: int() argument must be a string, a bytes-like object or a number, not 'list'&rdquo; 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, 2020 alecxe 7.5k points
0 votes
2 answers 1.1K views
1.1K 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 15 views
15 views
Problem: Hello all, I am a new student of Python programming. I am trying to make a program that will ask for different personal details from the user, and then print them all together in a single line. However, the program is encountering an error of TypeError ... am getting: TypeError: not enough arguments for format string I hope you&rsquo;ll come forward and help me to save my day. Thanks.
asked Jul 8, 2020 adamSw 11.3k points