osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Flag control variable


Op woensdag 12 februari 2014 06:23:14 UTC+1 schreef Dave Angel:
> luke.geelen at gmail.com Wrote in message:
> 
> > Can I make it that if
> 
> > C = int(sys.argv[3]) 
> 
> > But when I only enter 2 argumentvariable it sets c automaticly to 0 or 1
> 
> > 
> 
> 
> 
> Why do you ask for 'automatically'? You're the programmer,  write
> 
>  the test in the code. 
> 
> 
> 
> if len (sys.argv) == 3:
> 
>     sys.argv. append ("0")
> 
> 
> 
> But of course there are lots of other things you need to check, 
> 
>  so consider all of them at the same time. 
> 
> 
> 
> -- 
> 
> DaveA

then i keep getting IndexError: list index out of range
anyway to prevent it and just set the value to 0?