jeudi 18 mai 2023

How to print stuff on the same row

im writing a pyhton program that basically calculates the probability of the sum of a two dices. I'm using a print function to make a table, but apparently i can't print multiple stuff on the same row.

to get the sum of the dices i used the random libary, it looks like this:

question = int(input("How many times do you want to roll the dices: "))

def sum():
    for x in range(question):
       dice1 = random.randint(1,6)
       dice2 = random.randint(1,6)
       sum = dice1 + dice2
       print(sum)

def attempts():
      for attempts in rang(question):
             print(attempts)

Output:....

attempts        sum of the dices         probability
-----------------------------------------------------
    1
    2
    3 
                           4
                           9
                           3
                                                      100%
  • how do i make everything print in one column? thanks in advance for your help :/



Aucun commentaire:

Enregistrer un commentaire