dimanche 22 avril 2018

Blank text when using random package

I'm making a dice program and whenever I try to type "D4" (Since that's the only thing I have right now) I get the random numbers I coded in, then blank text.

I'm using:
Windows 10 Home
Python 3.6

This is my code:

from random import *
import os
import time
os.system('cls')

print("What dice would you like to roll?")

print("D4, D6, D10, D12, D20")

D4 = int(randint(1, 4))

D6 = int(randint(1, 6))

D10 = int(randint(1, 10))

D12 = int(randint(1, 12))

D20 = int(randint(1, 20))

age = int(D4)

diceI = input("Name: ")

if (diceI == D4):
    print("lol")

else:
    os.system('cls')
    time.sleep(.1)
    print("4")
    os.system('cls')
    time.sleep(.1)
    print("2")
    os.system('cls')
    time.sleep(.1)
    print("3")
    os.system('cls')
    time.sleep(.1)
    print("4")
    os.system('cls')
    time.sleep(.1)
    print("1")
    os.system('cls')
    time.sleep(.1)
    print("3")
    os.system('cls')
    time.sleep(.1)
    print("2")
    os.system('cls')
    time.sleep(.1)
    print(random.randint(1,4))

I understand that this is very messy code so I'll try and explain why I have certain things the way they are.

First of all, this: https://i.stack.imgur.com/6cvmD.png

The reason why I have this is because if I just try to have the "if" statement in the general the code, nothing shows up. That's why I just have it show up with the actual code in the else statement.

Second of all, this: https://i.stack.imgur.com/QBoj0.png

I know this can be very easily simplified, but the thing I'm trying to do is to show random numbers before the actual result comes in, giving the effect that it is actually a die that you're rolling.

I really hope somebody sees this, because I've been trying to fix it for around 5 days now.




Aucun commentaire:

Enregistrer un commentaire