我正在制作一个能够产生单一淘汰赛的计划.到目前为止,我的代码看起来像这样(我刚刚开始)
amount = int(raw_input("How many teams are playing in this tournament? "))
teams = []
i = 0
while i<amount:
teams.append(raw_input("please enter team name: "))
i= i+1
Run Code Online (Sandbox Code Playgroud)
现在我被卡住了.我想随机选择2个数字,这些数字将选择面向对方的球队.数字根本不能重复,并且必须从1到"数量".最有效的方法是什么?
我刚开始学习Python.我试图让用户输入一个数字基数和一个数字,并将其转换为十进制.
我一直在尝试使用内置的int函数,如下所示:
base = raw_input("what number base are you starting with? \n")
num = raw_input("please enter your number: ")
int(num,base)
Run Code Online (Sandbox Code Playgroud)
我的问题是当你使用那个int函数时,你的转换需要用引号来表示: int('fff',16)
我在使用变量时如何实现这一目标?