My code is this and im trying to make a coin flipper (The code might look weird because i recycled the script from a random joke selector i coded)
coinside = ['heads.png',
'tales.png',]
from random import randint
def pick(words):
num_words = len(words)
num_picked = randint(0, num_words - 1)
word_picked = words[num_picked]
return word_picked
print(pick(coinside))
while True:
print(pick(coinside))
input()
Since it is impossible to do this without external modules, if you want to work with images in python you need pillow.
you can find more information here: https://www.geeksforgeeks.org/working-images-python/
If all you want is a command-line coin flipper, you don't need that much code.
import random
coins = ['heads', 'tails']
while True:
print(random.choice(coins))
input()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.