How do i make input correct to be both lower and uppercase?
9 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Kalpha.mc
le 17 Nov 2020
Réponse apportée : Ameer Hamza
le 17 Nov 2020
I need to find out how to make this if statment to accept the imput as capital or lower case c.
Could someone please help me out with it ?
x = input('Answer is c or C','s');
if x ~= lower('C') ,or upper('c')
disp('incorrect')
elseif x == lower('C') ,or upper('c')
disp('correct')
end
0 commentaires
Réponse acceptée
Ameer Hamza
le 17 Nov 2020
Apply lower() on the input x
x = input('Answer is c or C','s');
if lower(x) ~= 'c'
disp('incorrect')
elseif lower(x) == 'c'
disp('correct')
end
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Characters and Strings dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!