Hi I'm trying to join sys.argv list items together with a space separator. I need to leave the first two indexes [0,1] and join up the rest into index [2] with a space between them. The sys.argv inputs are all strings too I don't get it. I am doing this inside a function is that it?
print(sys.argv)
elif len(sys.argv) > 3:
print(len(sys.argv))
sys.argv[2:(len(sys.argv)-1)] = [' '.join(sys.argv[2:(len(sys.argv)-1)])]
print(sys.argv[2])
print(sys.argv)
I keep getting this output:
['caesar.py', '46', 'chickens', 'room']
4
chickens
['caesar.py', '46', 'chickens', 'room']
What I need is this:
['caesar.py', '46', 'chickens', 'room']
4
chickens room
['caesar.py', '46', 'chickens room']
Thanks in advance everyone.