While Loop is not ending, just keeps repeating from top
Ältere Kommentare anzeigen
I am trying to create a guessing game where the user chooses from 3 colours, this is my script so far.
colour = {'Red','Green','Blue'}
x=colour{randi(numel(colour))}
guess = 0
while guess ~= 1
guess = input('Guess the colour, is it Red, Green, or Blue? ','s')
if(strcmp(guess,x)==1)
continue
else
display('Incorrect')
end
end
display('Correct')
Forgive my lack of not knowing how to organise this post a little better and thankyou in advance for your answers.
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Just for fun finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!