Hi everyone the code below to ask user to guess a word 'Sol'. The user has three attempts. also has the option to withdraw typing 'Pass'. can you help me make it work?
Sol = 'aaa' %is a char variable
Try = input('insert right world you have 3 trys: ','s') i = 0; if strcmpi(Try,'Pass'); P = input('are you sure to esc? [Y/N].\n','s'); if P =='Y' break; else continue; end elseif strcmpi(Try,Sol); fprintf('correct. continue? [Y/N].\n'); if P =='N' break; end else for i = 0:2 Try = input('...mmm retry: ','s') if strcmpi(Try,Sol) P = input('correct. continue? [Y/N].\n','s'); if P =='N' break; end break; end P = input('correct. continue? [Y/N].\n','s'); if P =='N' break; end end end
ps.: any suggestion to optimize the code is welcome
Best Answer