I like the method of showing the die with X's and 0's. But I would have written the code differently:
faces = ['X X X\nX 0 X\nX X X', '0 X X\nX X X\nX X 0', '0 X X\nX 0 X\nX X 0',
'0 X 0\nX X X\n0 X 0', '0 X 0\nX 0 X\n0 X 0', '0 X 0\n0 X 0\n0 X 0']
print(faces[random(6)]
Much simpler than all those if/elif statements.
(Oct-24-2018, 03:48 PM)Ablazesphere Wrote: [ -> ]while choice == 'n':
print("Goodbye")
print()
print("Coded by Muhammed©")
time.sleep(10)
break
Why have a while loop, if you'll never loop more than once? Remove the
break
, and just use an
if choice == "n":
instead.
(Oct-24-2018, 09:39 PM)nilamo Wrote: [ -> ] (Oct-24-2018, 03:48 PM)Ablazesphere Wrote: [ -> ]while choice == 'n': print("Goodbye") print() print("Coded by Muhammed©") time.sleep(10) break
Why have a while loop, if you'll never loop more than once? Remove the break
, and just use an if choice == "n":
instead.
Good idea but I used while loop purposely.
(Oct-26-2018, 10:12 AM)Ablazesphere Wrote: [ -> ]Good idea but I used while loop purposely.
Would you enlighten us what the purpose is?
Guys it doesn't take much time to leave a like. Please like I would appreciate it
(Oct-26-2018, 10:15 AM)buran Wrote: [ -> ] (Oct-26-2018, 10:12 AM)Ablazesphere Wrote: [ -> ]Good idea but I used while loop purposely.
Would you enlighten us what the purpose is?
What I am trying to say is whether you use a while loop or an if statement your bound to get a same output. Right?
(Oct-26-2018, 10:19 AM)Ablazesphere Wrote: [ -> ]What I am trying to say is whether you use a while loop or an if statement your bound to get a same output. Right?
There are many ways to do something. Don't you want to do it in the best/proper way? Also, you said you you did it purposely, i.e. there was specific reason to use while loop instead of just using the if statement. Now it just looks like you don't accept critique.
(Oct-26-2018, 10:39 AM)buran Wrote: [ -> ] (Oct-26-2018, 10:19 AM)Ablazesphere Wrote: [ -> ]What I am trying to say is whether you use a while loop or an if statement your bound to get a same output. Right?
There are many ways to do something. Don't you want to do it in the best/proper way? Also, you said you you did it purposely, i.e. there was specific reason to use while loop instead of just using the if statement. Now it just looks like you don't accept critique.
There is nothing wrong in what you said and i am not denying any critique. I used while loop to make the code look simpler.
What was really in my mind was,
while choice == 'y':
I used while loop for 'y'.
while choice == 'n':
Why not for 'n'. Got it?
Do whatever you want...
For the benefit of the other who may look at the thread
from random import choice
faces = ['X X X\nX 0 X\nX X X', '0 X X\nX X X\nX X 0', '0 X X\nX 0 X\nX X 0',
'0 X 0\nX X X\n0 X 0', '0 X 0\nX 0 X\n0 X 0', '0 X 0\n0 X 0\n0 X 0']
while True:
user_input = input("Press Enter to roll a dice. Press any other key to exit the simulator: ")
if user_input:
break
print(choice(faces))
print("Goodbye")
(Oct-26-2018, 11:11 AM)buran Wrote: [ -> ]Do whatever you want... For the benefit of the other who may look at the thread from random import choice faces = ['X X X\nX 0 X\nX X X', '0 X X\nX X X\nX X 0', '0 X X\nX 0 X\nX X 0', '0 X 0\nX X X\n0 X 0', '0 X 0\nX 0 X\n0 X 0', '0 X 0\n0 X 0\n0 X 0'] while True: user_input = input("Press Enter to roll a dice. Press any other key to exit the simulator: ") if user_input: break print(choice(faces)) print("Goodbye")
Ill do whatever i want and please keep your stupid comments to yourself. Try to be nice sometimes.
(Oct-26-2018, 11:20 AM)Ablazesphere Wrote: [ -> ] (Oct-26-2018, 11:11 AM)buran Wrote: [ -> ]Do whatever you want... For the benefit of the other who may look at the thread from random import choice faces = ['X X X\nX 0 X\nX X X', '0 X X\nX X X\nX X 0', '0 X X\nX 0 X\nX X 0', '0 X 0\nX X X\n0 X 0', '0 X 0\nX 0 X\n0 X 0', '0 X 0\n0 X 0\n0 X 0'] while True: user_input = input("Press Enter to roll a dice. Press any other key to exit the simulator: ") if user_input: break print(choice(faces)) print("Goodbye")
Ill do whatever i want and please keep your stupid comments to yourself. Try to be nice sometimes.
I am so sorry that you have been offended by a silly 3 letter word.