For an external application I need to send a command as a string, like this:
["START", "1", "2", "3", "4", "STOP"]
Note the double quotes!
I create this command with the following function:
def create_command(amount):
command = ["START"]
list = create_list(amount)
command += list
command += ["STOP"]
command = str(command )
command = command.replace("\'", "\"")
return command
And I create a list from a given number with the following function:
def create_list(data):
list = []
data = str(data)
for letter in data:
list.append(letter)
return list
Is the a way to make both functions more pythonic and not so straightforward? I don't really like them now, they look a bit clumpsy and I think there must be a better way do the thing.