Reputation: 37
I have the following code that causes the below error.
elif args[0]=="online":
onlines = zxLoLBoT.get_friends_online(self)
self.message(sender, "Toplam "+len(onlines)+" kişi açık.")
Upvotes: 1
Views: 148
Reputation: 13810
I would use .format()
to do it:
self.message(sender, "Toplam {} kişi açık.".format(len(onlines)))
This way you do not need to use extra code to convert int to str.
Upvotes: 4
Reputation: 5275
self.message(sender, "Toplam " + str(len(onlines))+ " kişi açık.")
You were trying to concatenate a string with an integer.
The built-in function len()
will always return an integer type, so you must convert it to a string with str()
when concatenating it another string.
len(...)
len(object)
Return the number of items of a sequence or collection.
Upvotes: 3