How do i make input correct to be both lower and uppercase?
12 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Kalpha.mc
am 17 Nov. 2020
Beantwortet: Ameer Hamza
am 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 Kommentare
Akzeptierte Antwort
Ameer Hamza
am 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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Characters and Strings finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!