vendredi 23 décembre 2016

how to get a variable then a string without a space in python

So I made this and it works, but I'm kinda picky so I want it to work 100% this is the code

import random
input_1 = str(input("Do you want to roll a dice? Enter y for yes anything else for no. "))
if input_1 == "y":
    dicesides = int(input("How many sides do you want your dice to have? "))
    diceroll = random.randint(1, dicesides)
    print("The dice rolled a",diceroll ".")
    input_2 = str(input("Do you want to roll the dice again? Same keys. "))
    while input_2 == "y":
        print(random.randint(1, dicesides))
        input_2 = str(input("Do you want to roll the dice again? Same keys. "))
    else:
        print("Okay, goodbye now.")

else:
    print("Okay, goodbye now.")

When I run it and it tells me the number it "rolled" it puts a space after the number, which I don't want. After I find out how I'll change the second+ dice roll to it.




Aucun commentaire:

Enregistrer un commentaire