Explore Courses Blog Tutorials Interview Questions
0 votes
in Python by (47.6k points)

I am a newbie programmer trying to make an IRC bot that parse XML and paste its content on a channel. Usually, I find my answer on google, but this time I can't find my answer.

q0tag = dom.getElementsByTagName('hit')[0].toxml() 

q0 = q0tag.replace('<hit>','').replace('</hit>','') 

q1 = (q0 * 1.2)

when I'm trying to multiply q0 it always showing

TypeError: can't multiply sequence by non-int of type 'float'.

I'm trying to make q0 int or float but it just makes another error

AttributeError: 'NoneType' object has no attribute 'replace'

q0 value is a round number without decimal.

1 Answer

0 votes
by (106k points)
edited by

To get rid of this error you need to do some changes in your q0 value which is still a string. This is basically what you're doing:

>>> q0 = '3' 

>>> q1 = (q0 * 1.2) 

Traceback (most recent call last): 

 File "<stdin>", line 1, in <module> 

TypeError: can't multiply sequence by non-int of type 'float'

To fix this error you need to convert the string to a number first by using the below-mentioned way:

>>> q1 = (float(q0) * 1.2

>>> q1 


To Learn what is python and python applications then visit this Data Science with Python Course.

For more information, kindly refer to our Python Certification course.

Related questions

0 votes
1 answer
asked Sep 25, 2019 in Python by Sammy (47.6k points)
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Browse Categories