0

What is my problem?

I am making an rpg game. My problem at the moment is that if you do not provide an input when naming your character (by pressing enter) your character does not receive a name.

what i want to be able to do: to provide the user with another opportunity to re-enter their name

My code for this segment of the game:

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')

please consider that i am a beginner and a solution that may seem obvious to you might not seem to be obvious to me

some_user_3
  • 403
  • 1
  • 5
  • 17
  • 1
    1 print('\n > what should your hero be named?\n ') 2 3 name = "" 4 while not name: 5 name = input('> ') 6 7 # i would need input to repeat here 8 9 time.sleep(1) 10 print(f'\n > welcome mighty hero! you shall be named: {name} !!!\n ') 11 print(' > a fine choice') 12 print('\n') – Luca Sans S Feb 19 '21 at 14:11
  • Create a name = ''. then while not name, name = input('> ') – Luca Sans S Feb 19 '21 at 14:12

0 Answers0