• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How Can I do it without using if condition

 
Bhairava Surya
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Consider a program accepts inputs like '4', or some string etc.

Using exceptions concept how can i display whether the input is number or string.. without using 'if condition'??

Thanks & Regards,
Ravi.
 
S. Nitesh
Ranch Hand
Posts: 36
1
Chrome Linux VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I think, this should work.
 
Bhairava Surya
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Nitesh,

Thanks for your immediate reply. But, can you give a complete code without if condition.
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which bit are you having a problem with ? Put that line of code in a try/catch block, add a couple of print statements and you're done. Give it a try. You'll learn more by trying it yourself than having the code given to you.
 
S. Nitesh
Ranch Hand
Posts: 36
1
Chrome Linux VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Chinna,
Did you work on Joanne's suggestion?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic