首页 > 解决方案 > 如果输入没有收到值,我该如何让输入重复?

问题描述

我的问题是什么?

我正在制作一个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')

请考虑到我是一个初学者,一个对你来说似乎很明显的解决方案对我来说可能并不明显

标签: python

解决方案


推荐阅读