python - How to replace "times" with "time" depending on the output -


import random total = [0] 1 = 0 2 = 0 3 = 0 4 = 0 5 = 0 6 = 0  dice=true while dice: = random.randrange(1,7) if == 1:     1 = 1 + 1 elif == 2:     2 = 2 + 1 elif == 3:     3 = 3 + 1 elif == 4:     4 = 4 + 1 elif == 5:     5 = 5 + 1 elif == 6:     6 = 6 + 1   b = len(total) print ("roll:", b,) print ("the dice has rolled:",a,) total.append (a)     dice =input("roll again? (y,n):") if dice == "n":     print ("thank-you!")     print ("one rolled",one,"times")     print ("two rolled",two,"times")     print ("three rolled",three,"times")     print ("four rolled",four,"times")     print ("five rolled",five,"times")     print ("six rolled",six,"times")      break 

how can make if "one" has been rolled "once" says "one has been rolled time" instead of "one has been rolled 1 times"?

thanks. explanation can learn

make function called printtimesrolled or similar. pass string, , int. this:

def printtimesrolled(numberword, timesrolled):     if (timesrolled == 1):         print(numberword, "rolled 1 time.")     else:         print(numberword, "rolled", timesrolled, "times.") 

then, print them all, this:

printtimesrolled("one", one) printtimesrolled("two", two) ... 

Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -