[Tutor] Question
Alan Gauld
alan.gauld at yahoo.co.uk
Mon Apr 10 14:45:07 EDT 2023
On 10/04/2023 15:27, Prayash Bhuyan wrote:
> I wanted to created a program that prompts the user for a name if the name
> is the list it will randomly generate a group to the name and then
> again should promt for the next name until all the name in the list is
> given as input.
You refer to a list. Is this the list of names entered? Or is it a list
of names that already exists somewhere?
You mention a group. What is that? Its ot a python term, so it must
mean something to you, but it doesn't mean anything to us until you
tell us.
> .But if a wrong name is given as input it should repromt the
> user again for name but should not consider to be one of the iteration of
> the one that runs when the name is in the list.
This implies that you are counting the iterations?
What do you do with the count? Does it limit how
many names you can enter? Or do you display the number at the end?
What is it for?
I am guessing that what you want looks like this in pseudo code:
validNames = sorted([lots of names here])
inputNames = []
count = 0
while sorted(inputNames) != validNames:
name = input(some prompt)
if (name in validNames) and (name not in inputNames):
inputNames.append(name)
count += 1
else: continue
Is that something like it?
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
More information about the Tutor
mailing list