Oct-26-2016, 02:55 PM
(Oct-26-2016, 02:33 PM)chris0147 Wrote: When I try this:
program_id = ('\n'.join(some_list)) ctrl = self.getControl(int(program_id))I will get an error: [b]ValueError: invalid literal for int() with base 10: '3001\n3011\n3021\n3031\n3041\n3051\n3061'
Any idea how I can fix this??
What are you trying to do? You're taking a list of things, and combining them it create a newline-separated string. All of those things, all at once, are not an int, they're just a string. Each individual item is an int, but all of them are just a big string. So fixing it depends on what you want to do. Do you want to loop over all of them and do something with each? And, if so, they probably shouldn't be joined together.
for program_id in some_list: ctrl = self.getControl(int(program_id)) # do something with this ctrl/program_id