Click here to Skip to main content
15,908,907 members

Comments by Prayash Bhuyan (Top 6 by date)

Prayash Bhuyan 10-Apr-23 9:26am View    
okay and thank you very much
Prayash Bhuyan 10-Apr-23 9:18am View    
I saw your solution and i really appreciate you trying to help me but this is also what i donot want i want suppose the list is [ayush,nayan,bhargav,niju,money]
the program runs and promts
type a name: ayush
ayush you group is 5
and then it shouldnot break it should be like
type a name:ayush
ayush your group is 5
type a name;bhargave
bhargav your group is 1
type a name: aaa(since it is not in the lst again promt type a name)
and this type a name promt should end only when all the write names in the list is over even in between ar in start the user enters a wrong name it should not consider it as a iteration of it owns
Prayash Bhuyan 10-Apr-23 4:50am View    
Also once the for loop runs if the user enters a wrong input it should not also count that as an iteration
Prayash Bhuyan 10-Apr-23 4:49am View    
I got what you said but what i am saying is that that works fine but i want the for loop to run only when the name is in the lsit and if not it should repromt the user but the promting message shouldnot be counted as iteration but in my programe it is counting it as a iteration...
Prayash Bhuyan 10-Apr-23 0:35am View    
For doing what i intended to do i cehcked the if statement first so it is not considering it to be interation but now the problem is if one name is in ht elist it prints all the name together and doesnot ask the user for names again and again

import random
names=["ayush","bhargav","nayan","money","niju"]
active=True
while active:
name=input("what is your name: ")
if name in names:
for name in names:
name=name.casefold()
group=random.randint(1,5)
print(name,"your group is",group)
active=False
else:
continue