I have an object whose data i want to display via tkinter Labels. In the object there is a list with strings in it.
I want to display the items seperated by a comma. For now I have this:
self.newString = "Items: " for item in self.Obj.list: if self.Obj.list.index(item) == 0: # This seems very un-pythonic, but it works ¯_(ツ)_/¯ self.newString = self.newString + item else: self.newString = self.newString + f", {item}"
I know that there is a better way of doing this but dont know how.
submitted by /u/noob_main22
[link] [comments]
r/learnpython I have an object whose data i want to display via tkinter Labels. In the object there is a list with strings in it. I want to display the items seperated by a comma. For now I have this: self.newString = “Items: ” for item in self.Obj.list: if self.Obj.list.index(item) == 0: # This seems very un-pythonic, but it works ¯_(ツ)_/¯ self.newString = self.newString + item else: self.newString = self.newString + f”, {item}” I know that there is a better way of doing this but dont know how. submitted by /u/noob_main22 [link] [comments]
I have an object whose data i want to display via tkinter Labels. In the object there is a list with strings in it.
I want to display the items seperated by a comma. For now I have this:
self.newString = "Items: " for item in self.Obj.list: if self.Obj.list.index(item) == 0: # This seems very un-pythonic, but it works ¯_(ツ)_/¯ self.newString = self.newString + item else: self.newString = self.newString + f", {item}"
I know that there is a better way of doing this but dont know how.
submitted by /u/noob_main22
[link] [comments]