Skip to main content
Stack Overflow
  1. About
  2. For Teams

Return to Question

Post Timeline

I have this code toin python 3,to check for errors on input but i need to determine that the input is an integer and if not to print the error message.

can anyone help me to figure out the code in my while loop. Thanks

price = 110;
ttt = 1;
while price < 0 or price > 100:
 
 price = input('Please enter your marks for Maths:');
 ttt =ttt +1;
 if ttt >= 2:
 print( 'This is an invalid entry, Please enter a number between 0 and 100';100')

I have this code to check for errors on input but i need to determine that the input is an integer and if not to print the error message.

can anyone help me to figure out the code in my while loop. Thanks

price = 110;
ttt = 1;
while price < 0 or price > 100:
 
 price = input('Please enter your marks for Maths:');
 ttt =ttt +1;
 if ttt >= 2:
 print 'This is an invalid entry, Please enter a number between 0 and 100';

I have this code in python 3,to check for errors on input but i need to determine that the input is an integer and if not to print the error message.

can anyone help me to figure out the code in my while loop. Thanks

price = 110;
ttt = 1;
while price < 0 or price > 100:
 
 price = input('Please enter your marks for Maths:');
 ttt =ttt +1;
 if ttt >= 2:
 print( 'This is an invalid entry, Please enter a number between 0 and 100')
Source Link
miguel
  • 245
  • 1
  • 3
  • 8

Python while loops

I have this code to check for errors on input but i need to determine that the input is an integer and if not to print the error message.

can anyone help me to figure out the code in my while loop. Thanks

price = 110;
ttt = 1;
while price < 0 or price > 100:
 
 price = input('Please enter your marks for Maths:');
 ttt =ttt +1;
 if ttt >= 2:
 print 'This is an invalid entry, Please enter a number between 0 and 100';
lang-py

AltStyle によって変換されたページ (->オリジナル) /