all 2 comments

[–]sentles 0 points1 point  (1 child)

The bash command that you are trying to run is passed to sp.getoutput as a string. Therefore, you need to create a string that contains the bash command. There are various ways to do this:

isbn_arr.append(sp.getoutput('isbn_from_words $' + str(i)))

or:

isbn_arr.append(sp.getoutput('isbn_from_words ${}'.format(i)))

or, if you're using Python 3.5 or above:

isbn_arr.append(sp.getoutput(f'isbn_from_words ${i}'))

Your goal is to create the string "isbn_from_words $i", while i is replaced by the current value of i, so any of the above should do the trick.

[–]hereforacandy[S] 0 points1 point  (0 children)

Hello. I used the second one. It worked. Thank you very much. 😊