Better way of defining similar variables at once (Python 2.7) -
i'm solving problem requires me convert each alphabet of 9 letter string variable.
this current code
number = input("enter nine-digit number here \n") string = str(number) d1 = string[0] d2 = string[1] d3 = string[2] d4 = string[3] d5 = string[4] d6 = string[5] d7 = string[6] d8 = string[7] d9 = string[8]
is there better way of defining of these variables?
it felt there should couldn't think of how.
since string sequence can perform sequence unpacking on it'll still force use several variables.
a = str(1234) b,c,d,e = >> b >> '1' >> c >> '2'
and forth.
Comments
Post a Comment