in windows: I would like this program to run on commandline. However, I am getting an error. What am I doing wrong?
# create a method that append the letter stored in variable letter, ntimes.
import sys
def appender(letter,ntimes, sentence):
print sentence+(letter*ntimes)
appender(str(sys.argv[1]),sys.argv[2], str(sys.argv[3]))
The below is the error i get from command line in windows
C:\Users\QamarAli\Documents\afaq's stuff>appender.py "F" 10 "Hello this is sent"
Traceback (most recent call last):
File "C:\Users\QamarAli\Documents\afaq's stuff\appender.py", line 8, in <modul
e>
appender(str(sys.argv[1]),sys.argv[2], str(sys.argv[3]))
File "C:\Users\QamarAli\Documents\afaq's stuff\appender.py", line 5, in append
er
print sentence+(letter*ntimes)
TypeError: can't multiply sequence by non-int of type 'str'
C:\Users\QamarAli\Documents\afaq's stuff>