python - Need help splitting a string into 3 variables -
i split string of characters 3 variables. when run .split()
['aaa00000011']
. split like:
var1 = aaa var2 = 0000001 var3 = 1
the user typing in these values command line on windows machine.
my code:
barcode = raw_input('please enter barcode') print "this barcode split up", barcode.split()
are looking this?
var1 = barcode[:3] # first 3 characters var2 = barcode[3:-1] # characters third next-to-last var3 = barcode[-1] # last character
Comments
Post a Comment