- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在制作一个闪存卡程序来帮助我记住 python 关键字和术语。但有时它会重复我的答案,这对任何人来说都是显而易见的。
What is: Exception 1- Another name for runtime error 2- Another name for runtime error 3- The meaning of a program
那么如何避免这种重复呢?
while count < 10:
os.system('clear')
wordnum = random.randint(0, len(F1c)-1)
print "What is: ", F1c[wordnum], ""
options = [random.randint(0,len(F2c)-1),random.randint(0,len(F2c)-1),
random.randint(0,len(F2c)-1)]
options[random.randint(0, 2)] = wordnum
print '1 -', F2c[options[0]],
print '2 -', F2c[options[1]],
print '3 -', F2c[options[2]],
answer = input('\nYou choose number ?:')
if options[answer-1] == wordnum:
raw_input('\nCorrect! Hit enter...')
score = score + 1
else:
raw_input('\nWrong! Hit enter...')
count = count + 1
print '\nYour score is:', score
最佳答案
现在您没有做任何事情来确保第二个和第三个选择的选项不会与第一个发生冲突。为此,您可以在选择第二个之前从列表中删除第一个选择的选项,依此类推。
然而,python 标准库中有函数已经实现了从列表中仔细选择多个项目:
answers = random.sample(F2c, 3)
或者选择索引:
options = random.sample(range(len(F2c)), 3)
关于python-2.7 - 避免在 python 中重复回答,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22981033/
package homework4; import java.util.Scanner; public class Prog4 { static Scanner scanner = new Scann
很多信使/应用程序发送Android通知,我可以在不打开应用程序的情况下直接在通知中回复。例如,此功能在 WhatsApp 或 Telegram 中。 我现在的问题是,如何做到这一点? //更新: 这
我在一些帮助文件和 src 文档中看到了很多这样的图表 他们叫什么?是否有任何其他(出于相同目的)已知图表? 图片来源:http://www.sqlite.org/images/syntax/inse
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 想改进这个问题?将问题更新为 on-topic对于堆栈溢出。 1年前关闭。 Improve this qu
我有要解析的大 (>1Mb)、简单的 JSON 文件。 我使用了 Aeson,按照他们在 Haskell 学校的 fpcomplete 教程(谢谢你们,顺便说一句)。 由于某些文件(而不是全部)失败,
我最近一直在阅读有关NLP的文章,到目前为止,我已经(非常)基本了解所有工作原理,包括从句子拆分到POS标记以及知识表示。 我知道那里有各种各样的NLP库(主要是Java或Python),并且找到了.
在 destroy.js.erb 中有效 $("").appendTo("#commentlist"); 瘦身怎么做?我试过了 $("= escape_javascript(render @comme
考虑一个类 OriginalClass,它可能在运行时可用,也可能不可用。 OriginalClass 有一个方法 doSomething 如果它的类可用,应该执行该方法。 解决这个问题的一种方法是创
当我添加延迟命令时,paramiko 返回“2”作为退出状态(同时返回“0”用于带宽命令设置)。 2还好吗? (谷歌搜索对此没有帮助,我猜 2 一定是某种错误)。 我使用的命令是:- delay_cm
当我运行这个命令时: tc qdisc add dev eth0 root red limit 51200000 min 128000 max 512000 avpkt 1024 burst 200
我试图创建一个网络接口(interface)的新实例以在其上设置 DNS 服务器配置。 当我运行此命令时: ip link set enp1s0 name ens33 && ip link set e
我的页面上有一个对话框,它是使用 JQuery 对话框小部件制作的。我已经将两个按钮设置为具有单击页面上不同按钮的功能,这将触发页面的回发并执行各种操作。当对话框为modal: false时,对话框将
现在我正在使用 gnus通过从 gwene 订阅感兴趣的标签来阅读 SO 问题。 我只能看到/阅读问题而不是答案。 是否有插件可以回答/询问 SO 问题。当然,我可以使用 edit-server 来编
我正在使用 Jenkins slack 插件在我的自动构建过程中向我发送消息。我已经设置了手动门控,因此生产部署需要手动批准。这是使用 Jenkins input 完成的。步。 我该如何回应这个inp
我的技能是让你可以开始新游戏。不过,如果用户正在 session 中玩游戏或想要开始新游戏,我会在 game_in_progress 中放置一个 session 变量。它显示,“游戏正在进行中,您想继
我想知道决策算法的名称是什么,它不返回"is"或“否”,但只能为输入的真实子集决定"is",不能提供对其余部分做出最终决定。 一个合适的例子是确定矩阵可逆性的算法——我的算法对矩阵的一个子类正确回答"
1. ETH=$1 2. LATENCY=$2 3. LOSS=$3 4. JITTER=$4 5. BW=$5 6. sudo /sbin/tc qdisc del dev eth0 root 7.
我正在寻找一种方法来回答 golang 中的 shell 密码提示。 喜欢: bussiere@kus:~/Workspace/rteest$ ./passwordtest.sh Password :
我们在我们的 web 应用程序中通过 wro 提供 javascript 资源(和其他资源)。 在 PROD 环境中,浏览器获取(例如)app.js angular webapp 的内容,其中包含 f
我有一个 .xlsm 文件,我需要其中一些以非宏文件格式 (.xlsx) 保存的工作表。为此,我创建了以下代码。第一部分将事件工作表(称为“CombinedRaw”)保存为单独的文件“DATATRY.
我是一名优秀的程序员,十分优秀!