Python-Help ( Mean,Median & Mode)

Cousin Stanley CousinStanley at HotMail.Com
Sun Dec 5 17:06:12 CET 2004


| I revised my source code. It was doing great
| but I'm having problem listing all the numbers
| that I'd input.
|
| How can I input all the numbers that I selected?

Alfred ....

   As a method to list the numbers that have been input
   and avoid having to know in advance how many numbers
   are needed, you might consider a simple input mode
   where a character other than an integer is input
   as a  stop-input-mode  character ....

print '\n    Input an integer at the  >  prompt \n'
print '    Enter a period  .  to end input mode'
print '    and begin processing .... \n'

prompt = '> '
period = '.'

list_input = [ ]

while True :

     this_str = raw_input( prompt )

     if this_str  ==  period :

         break

     try :

         list_input.append( int( this_str ) )

     except :

         print '\n    Input Must be an Integer'
         print '    or a period  .  to exit Input Mode \n'

num_entries = len( list_input )

print '        Input List .... \n'

for this_item in list_input :

     print '        %s' % this_item

print '\n        # Entries .... %s \n' % num_entries


-- 
Cousin Stanley
Human Being
Phoenix, Arizona



More information about the Python-list mailing list