Burge Kurt wrote: >>divmod(...) >> divmod(x, y) -> (div, mod) > > > What is the easiest way to use div and mod seperately as an attribute like: > > if a = divmod(x,y) > > a.div or a.mod
The result of calling divmod() is a two-element tuple. You access the elements by indexing: >>> a=divmod(10, 3) >>> a[0] 3 >>> a[1] 1 You can also use tuple assignment to assign the two values to two variables (you can use other names than div and mod): >>> div, mod = divmod(10, 3) >>> div 3 >>> mod 1 BTW you can't put an assignment in an if statement in python so your original code might be written as div, mod = divmod(x, y) if div... Kent _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor