[Tutor] Trivia program.
Hi, I got a problem with this program. name = raw_input("Hi. What's your name? ")called = name * 5print "\nIf a small child were trying to get your attention, " \ "your name would become:"print called When i input the name like "John Goodman" it prints like... John GoodmanJohn GoodmanJohn GoodmanJohn GoodmanJohn Goodman But i want to print it like... John Goodman John Goodman John Goodman John Goodman John Goodman How can I do it?Express yourself instantly with MSN Messenger! MSN Messenger Download today it's FREE! ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Trivia program.
Mmmhh ... one very simple way would be to replace your first line by : name = raw_input(Hi. What's your name? ) + But if you want to keep the name as it is, I bet the best way is to replace your second line by : called = .join([ name for i in xrange(5) ]) The advantage of this second method is theis added only *between* the names, and not after ... Pierre . Sm0kin'_Bull a écrit : Hi, I got a problem with this program. name = raw_input(Hi. What's your name? ) called = name * 5 print \nIf a small child were trying to get your attention, \ your name would become: print called When i input the name like John Goodman it prints like... John GoodmanJohn GoodmanJohn GoodmanJohn GoodmanJohn Goodman But i want to print it like... John Goodman John Goodman John Goodman John Goodman John Goodman How can I do it? Express yourself instantly with MSN Messenger! MSN Messenger http://g.msn.com/8HMBEN/2728??PS=47575 Download today it's FREE! ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor -- Pierre Barbier de Reuille INRA - UMR Cirad/Inra/Cnrs/Univ.MontpellierII AMAP Botanique et Bio-informatique de l'Architecture des Plantes TA40/PSII, Boulevard de la Lironde 34398 MONTPELLIER CEDEX 5, France tel : (33) 4 67 61 65 77fax : (33) 4 67 61 56 68 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Trivia program.
On Feb 16, 2005, at 10:26, . Sm0kin'_Bull wrote: it prints like... John GoodmanJohn GoodmanJohn GoodmanJohn GoodmanJohn Goodman But i want to print it like... John Goodman John Goodman John Goodman John Goodman John Goodman How can I do it? Try replacing the called = name * 5 line with: if not name.endswith(' '): called = ((name + ' ') * 5).strip() else: called = (name * 5).strip() -- Max maxnoel_fr at yahoo dot fr -- ICQ #85274019 Look at you hacker... A pathetic creature of meat and bone, panting and sweating as you run through my corridors... How can you challenge a perfect, immortal machine? ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Trivia program.
Or name = raw_input(Hi. What's your name? ) called = %s % name On Wed, 16 Feb 2005 11:46:09 +0100, Pierre Barbier de Reuille [EMAIL PROTECTED] wrote: Mmmhh ... one very simple way would be to replace your first line by : name = raw_input(Hi. What's your name? ) + But if you want to keep the name as it is, I bet the best way is to replace your second line by : called = .join([ name for i in xrange(5) ]) The advantage of this second method is theis added only *between* the names, and not after ... Pierre . Sm0kin'_Bull a écrit : Hi, I got a problem with this program. name = raw_input(Hi. What's your name? ) called = name * 5 print \nIf a small child were trying to get your attention, \ your name would become: print called When i input the name like John Goodman it prints like... John GoodmanJohn GoodmanJohn GoodmanJohn GoodmanJohn Goodman But i want to print it like... John Goodman John Goodman John Goodman John Goodman John Goodman How can I do it? Express yourself instantly with MSN Messenger! MSN Messenger http://g.msn.com/8HMBEN/2728??PS=47575 Download today it's FREE! ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor -- Pierre Barbier de Reuille INRA - UMR Cirad/Inra/Cnrs/Univ.MontpellierII AMAP Botanique et Bio-informatique de l'Architecture des Plantes TA40/PSII, Boulevard de la Lironde 34398 MONTPELLIER CEDEX 5, France tel : (33) 4 67 61 65 77fax : (33) 4 67 61 56 68 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor -- 'There is only one basic human right, and that is to do as you damn well please. And with it comes the only basic human duty, to take the consequences. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor