Ok so Im having a problem when printing something
Error:
TypeError: can only concatenate str (not "Element") to str
Code:
print(('Currently the weather in '+ query + 'is' + weath + 'with the temperature at ' + temp + 'degrees celsius'))
Ok so Im having a problem when printing something
Error:
TypeError: can only concatenate str (not "Element") to str
Code:
print(('Currently the weather in '+ query + 'is' + weath + 'with the temperature at ' + temp + 'degrees celsius'))
For a custom string representation of an instance
class A:
def __init__(self, value):
self.value = value
def __str__(self):
return self.value
print('string ' + str(A('concatenation')))
#string concatenation
Without __str__
class B:
def __init__(self, value):
self.value = value
print('string ' + str(B('concatenation')))
#string <__main__.B object at 0x7f91f5dd5040>