首页 > 解决方案 > How to create an auto increment seed in in python , making a heads or tails game?

问题描述

I've ended up with this code but I don't want to create a seed number on my own and want to by created by python:

 import random   
 test_seed = int(input("Create a seed number"))   
 random.seed(test_seed)   
 random_side = random.randint(0, 1)   
 if random_side == 1:   
     print("Heads")  
 else:
     print("Tails")

See if you can help me!

标签: pythonpycharm

解决方案


您可以通过根本不提供种子来自动增加种子。

代替: random.seed(test_seed)

利用: random.seed()

这将根据系统时间为您提供种子,因此会自动增加(除非时间因某种原因停止)。


推荐阅读