Hi I am just starting to learn python and it is so exciting!
I am reading this book : https://automatetheboringstuff.com
And if I follow the instructions everything works out, but I have tried to modify things on my own and can't seem to find the logic to it sometimes.
On chapter 2 there is this exercise:
name = ''
while not name:
print('Enter your name:')
name = input()
print('How many guests will you have?')
numOfGuests = int(input())
if numOfGuests:
print('Be sure to have enough room for all your guests.')
print('Done')
And it works fine, however if numOfGuests is not a number I get this error:
ValueError: invalid literal for int() with base 10: ''
My logical thinking was that I can also include that block into a loop with the while command, and tell the program that if the numOfGuests != int it should continue and go back to the print('How many guests will you have?') section.
Can someone help me understand how to make it work?
Thanks!