Reputation: 169
apple_orange<-readline(prompt="Enter your fruit: ")
while((apple_orange!="apple")||(apple_orange!="orange"))
{
apple_orange<-readline(prompt="Enter your fruit: ")
}
It keeps on Looping even when I type apple or orange .. What am I doing wrong here?
Upvotes: 2
Views: 106
Reputation: 93761
Your condition says to keep the loop going if apple_orange
!= "apple" OR apple_orange
!= "orange". One of those conditions will always be true, making the overall condition true, so the loop keeps going. Just change the OR to an AND.
Upvotes: 1