+ 1
My code below is supposed to take a number as input and output the color name at that index. Please explain where I went wrong.
https://code.sololearn.com/ckf66M7SCB8i/?ref=app My code only prints Red[1] 1 no matter what number you input.
3 Answers
+ 4
kody marsh
Equality operator: "==".
But it would be better that way:
if(0<x & x<=10){
cat(colors[x])
}else{
cat("Please input a number between 1-10")
}
P. S: "If you want to address someone personally, then click @ and a list of users will open."
+ 6
Use == instead of <- in if-else statements
+ 2
Thank you Solo and Hasnain [ACTIVE CHALLENGER] for the help!