On 28/10/12 21:37, Sandra Beleza wrote:

def GetNames():
     names=[]
     while len(names)<3:
         name=raw_input("Name: ")
         if name in names:
             print name, "is already in the data. Try again."
         if name not in names:
             names.append(name)
     names.sort()

You should probably stop your function here by returning names.


     for each in names:
         print "Hurray for", each +"!"
     print

It's good practice to keep the presentation logic outside
the function. Your loop would then change to

for each in getNames():
   ...

However I cannot use the len() built in function. The Teacher is asking
for another solution that does not use the len() t

That's bizarre. It forces you to write a bad solution.
However, Mark has already given you the necessary hint.
But using len() is absolutely the sane way to do this
(unless you are paranoid about micro performance).


--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to