Question #348703

Answer to Question #341372 in Python



Note:Error is displaying in this code, please correct it

Enter the number of societies:Keep the number of people in societies:

Traceback (most recent call last):

 File "main.py", line 4, in <module>

  num_people = int(input('Keep the number of people in societies:'))

ValueError: invalid literal for int() with base 10: '\r'


Expert's answer

try:
    num_people = int(input('Keep the number of people in societies:'))
except ValueError:
    print('You can only enter numbers')

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS