How do i make input correct to be both lower and uppercase?

17 次查看(过去 30 天)
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

采纳的回答

Ameer Hamza
Ameer Hamza 2020-11-17
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 个)

类别

Help CenterFile Exchange 中查找有关 Characters and Strings 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by