Hick Hick - 16 days ago 6
Python Question

Converting integer to string in Python?

I want to convert an integer to a string in Python. I am typecasting it in vain:

t=raw_input()
c=[]
for j in range(0,int(t)):
n=raw_input()
a=[]
a,b= (int(i) for i in n.split(' '))
d=pow(a,b)
d.str()
c.append(d[0])
for j in c:
print j


When I try to convert it to string, it's showing an error like
int
doesn't have any attribute called
str
.

Answer
>>> str(10)
'10'
>>> int('10')
10

[Edit]

Links to the documentation:
int()
str()

[Edit]

The problem seems to come from this line: d.str()
Conversion to string is done with the builtin str() function, which basically calls the __str__() method of its parameter.

Also, it shouldn't be necessary to call pow(). Try using the ** operator.