python - 如果输入没有收到值,我该如何让输入重复?
问题描述
我的问题是什么?
我正在制作一个rpg游戏。我目前的问题是,如果您在命名角色时(按回车键)不提供输入,则您的角色不会收到名称。
我希望能够做的:为用户提供另一个机会来重新输入他们的名字
我对这部分游戏的代码:
print('\n > what should your hero be named?\n ')
name = input('> ')
# i would need input to repeat here
time.sleep(1)
print(f'\n > welcome mighty hero! you shall be named: {name} !!!\n ')
print(' > a fine choice')
print('\n')
请考虑到我是一个初学者,一个对你来说似乎很明显的解决方案对我来说可能并不明显
解决方案
推荐阅读
- typescript - 防止 VSCode 折叠 Observable
到可观察的 - c++ - 使用 gcc 内联汇编可以将 %r# 寄存器设置为输入约束吗?
- python - 高斯混合模型 (GMM) 的期望最大化算法 (EM)
- javascript - 如何使用 JavaScript 读取没有父根名称的 JSON?
- android-studio - Android Studio/IntelliJ 如何决定 iml 文件名?
- r - 如何对组内的特定尺寸进行抽样?
- facebook - Facebook 图形 api 获取新闻源数据
- mysql - 我想从 wordpress 数据库中进行选择
- python - 如何使用 Selenium WebDriver for IE 和 Python 查找过滤器按钮的元素:
- javascript - javascript将json数据迭代到geojson中以获取传单