Conditional statement that will prevent users from imputing

  • Thread starter Thread starter GreenPrint
  • Start date Start date
  • Tags Tags
    Conditional
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
2 replies · 1K views
GreenPrint
Messages
1,186
Reaction score
0

Homework Statement



I was wondering if anyone knows of a conditional statement that will prevent users from imputing non integer inputs.

like for example
z=0
while z<1
x=input('Enter Something')
if SOME MAGICAL CONDITIONAL STATEMENT
disp('You entered a invalid entry. Please try again.')
else
z=1;
end
end

I hope you get what I'm trying to do. In a loop prompt a user to enter a number. If the user enters a number like 5.5 I would like the message to come up 'You entered a invalid entry. Please try again.' by using some conditional statement

anyone got any ideas?

Homework Equations





The Attempt at a Solution

 
Physics news on Phys.org


Does the computer language that you're using have INT() or floor() functions?