really appreciate that answer thanks very much.......... Adrian Kelly 1 Bramble Close Baylough Athlone County Westmeath
0879495663 From: waynejwer...@gmail.com Date: Wed, 16 Nov 2011 09:59:50 -0600 Subject: Re: [Tutor] modulus To: kellyadr...@hotmail.com CC: tutor@python.org On Wed, Nov 16, 2011 at 9:46 AM, ADRIAN KELLY <kellyadr...@hotmail.com> wrote: Please can anyone tell me how i can print this without all the brackets and commas, i know i need the modulus symbol but i dont know how it works. any advice would be appreciated regards adrian def arguments(): name=raw_input ("Please enter your firstname: ") surname=raw_input ("Enter your surname: ") address1=raw_input ("Enter Address line 1: ") address2=raw_input ("Enter Address line 2: ") address3=raw_input ("Enter Address line 3: ") return name,surname,address1,address2,address3 address=arguments() print "%s %s" % address In this case it's not actually modulus, it's just the syntax for string formatting. I'm not sure *what* the reasoning behind the % was, but that's the way it is. There are two ways to do string formatting, the new (.format) and old (%). In new style formatting you use the .format method of the string: "{0} {1} {2}".format("One", 2, "Five") You don't usually have to worry about the type, though you can specify it along with some other useful modifiers for precision, spacing, and alignment. In old style formatting, you use a string with format specifiers (%s, %d, etc.) followed by a tuple of arguments. Here, the lengths have to match exactly - if you have one specifier then you must have a 1-element tuple. In your case, you're returning a 5 element tuple, so you want 5 format specifiers: print "%s %s %s %s %s" % address However, if you just want to print the data out like that you can do it a little easier like this: print ' '.join(address) Or if you are in 3.x or use `from __future__ import print_function` then you can do this: print(*address) HTH, Wayne
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor