how to pass command line string arguments and compare them python
Question: i want to comapre two strings by passing one string from command prompt, this
is sample code, when I pass `c://python sample.py x`, it is storing x1 as
x1=[' x '] now if I compare `sys.argv[1:]` with string 'x' its false, may be
its comparing `[' x '] == 'x'`, how should I remove that square brackets and
single quotes around my input after it reads

`import sys` `print sys.argv[1:]` `x1=sys.argv[1:]` `print x1`

`if x1=='x':` `print "true"`


Answer: You are trying to compare a list with a string here.

Do

    
    
    x1 = sys.argv[1]
    

instead of

    
    
    x1 = sys.argv[1:]
    

