!USING PYTHON 3.1!
Hello DaniWeb! Today I'm going to teach you a cool variable trick that I learned. So here's an example:
a, b, c = input('?x?x?: ').split('x')
Now let's input something like:
>>> a, b, c = input('?x?x?: ').split('x') ?x?x?: 1x2x3
Now, variable 'a' is set to 1, variable 'b' is set to 2, variable 'c' is set to 3. I hope I explained that well enough. It can be used in various sections. NOTE: Because you used 3 variables, you have to have three answers divided by the character you split with. If you only used 'a, b' you would only be able to do '1x2'.
Now lets use another example using more common names:
breakfast, lunch, dinner = input('breakfast&lunch&dinner').split('&')
Now if we run this in idle the result is:
>>> breakfast, lunch, dinner = input('breakfast&lunch&dinner: ').split('&') breakfast&lunch&dinner: sausage&pizza&chicken
breakfast = sausage lunch = pizza dinner = chicken
That's going to be it for this tutorial! Hope you find it useful!