I am making special dice and don't know how to make each random number say something when it happens | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

I am making special dice and don't know how to make each random number say something when it happens

I am making special dice and don't know how to make each random number say something when it happens. Here is my code so far: import random for i in range(10): value=random.randint(1,8) if value==1: print("threat") if value==2: print("failure")

21st Aug 2016, 1:12 AM
Ezie
2 Answers
+ 3
you need to use if-else statement if A: a elif B: b elif C: c
21st Aug 2016, 1:14 AM
june song
june song - avatar
0
or dictionary. dic={1:"threat",2:"failure"...} print(dic[value])
21st Aug 2016, 2:52 PM
aruluth
aruluth - avatar