Re: Creating dice game : NEED HELP ON CHECKING ELEMENTS IN A LIST

2018-10-10 Thread Abdur-Rahmaan Janhangeer
*if any(roll != 1 and roll != 5 for roll in result):* another extract of py's beauty! Abdur-Rahmaan Janhangeer https://github.com/Abdur-rahmaanJ Mauritius -- https://mail.python.org/mailman/listinfo/python-list

Re: Creating dice game : NEED HELP ON CHECKING ELEMENTS IN A LIST

2018-10-10 Thread Neil Cerutti
On 2018-10-06, eliteanarchyra...@gmail.com wrote: > Hi, I am new to python and would like someones help on the > following: > > After rolling 5 dice and putting the results into a list, I > need to check if any dice is not a 1 or 5. if any(roll != 1 and roll != 5 for roll in result): > # - T

Re: Creating dice game : NEED HELP ON CHECKING ELEMENTS IN A LIST

2018-10-06 Thread bob gailer
# your program is quite complicated. classes are overkill. A simpler solution is: import random for i in range(5):     roll = random.randint(1,6)     if roll not in (1,5):     print('you can roll again')     break else:     print("you have all 1's and 5's in your result'") # comments on 

Re: Creating dice game : NEED HELP ON CHECKING ELEMENTS IN A LIST

2018-10-06 Thread eliteanarchyracer
Well these worked like a charm. Cant say I understand some of them and will have to look into utilizing them in the future, but I appreciate everyones responses and thank you all. Never needed to check for multiple instances in a list before. Nice to have help! -- https://mail.python.org/mailm

Re: Creating dice game : NEED HELP ON CHECKING ELEMENTS IN A LIST

2018-10-06 Thread Alister via Python-list
On Sat, 06 Oct 2018 21:56:09 +0200, Thomas Jollans wrote: > On 06/10/2018 20:10, eliteanarchyra...@gmail.com wrote: >> # - THIS LINE IS WHERE I NEED HELP # ( if 2, 3, 4, 6 in list: >> ) >> print("you can roll again") >> else: >> print("you have all 1's and 5's in your result") >

Re : Creating dice game : NEED HELP ON CHECKING ELEMENTS IN A LIST

2018-10-06 Thread armand.fouca...@telecom-bretagne.eu
You could use any and a generator expression. It sounds pretty hard, but it's actually easily expressed, and pretty intelligible. Here you go: if any(n in result for n in [2, 3, 4, 6]): # reroll else: # do your thing - Arma

Re: Creating dice game : NEED HELP ON CHECKING ELEMENTS IN A LIST

2018-10-06 Thread Thomas Jollans
On 06/10/2018 20:10, eliteanarchyra...@gmail.com wrote: # - THIS LINE IS WHERE I NEED HELP # ( if 2, 3, 4, 6 in list: ) print("you can roll again") else: print("you have all 1's and 5's in your result") You can use a loop: for good_number in [2,3,4,6]: if good_number in

Re: Creating dice game : NEED HELP ON CHECKING ELEMENTS IN A LIST

2018-10-06 Thread MRAB
On 2018-10-06 19:10, eliteanarchyra...@gmail.com wrote: Hi, I am new to python and would like someones help on the following: After rolling 5 dice and putting the results into a list, I need to check if any dice is not a 1 or 5. if all dice in the list are either a 1 or 5 , I want to calculate