Python 3 - How to randomize what text displays
<p>I am a beginner at python and I am trying to figure out how I can randomly display text. For example, 60% chance of "Hello", 40% chance of saying "Goodbye", etc. Right now, for fun, I am trying to create sort of a bottle flip game. If you don't know what it is, its basically when you flip a half empty water bottle and try to land it. This is what I have: (This is more than likely completely wrong.)</p>

<pre><code>import random

number = random.randrange(10)

if number == "1":
    print ("You have landed the bottle!")
elif number == "2":
    print ("You have landed the bottle!")
elif number == "3":
    print ("You have landed the bottle!")
elif number == "4":
    print ("You have landed the bottle!")
elif number == "5":
    print ("The bottle did not land, better luck next time.")
elif number == "6":
    print ("The bottle did not land, better luck next time.")
elif number == "7":
    print ("The bottle did not land, better luck next time.")
elif number == "8":
    print ("The bottle did not land, better luck next time.")
elif number == "9":
    print ("The bottle did not land, better luck next time.")
elif number == "10":
    print ("The bottle landed on the cap!")
</code></pre>

<p>You could also use a list of the possible solutions.</p>

<pre><code>import random
possibilities=['landed'] * 3 + ['missed'] * 6 + ['landed on cap'] 
print(random.choice(possibilities))
</code></pre>

python python-3.x random