Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 5
🔥🅳🅴🆅 🅼🅸🆂🅷🆁🅰🔥 did you mean to compare integers or words/strings f = as.integer(f) i = as.integer(i)
9th Sep 2022, 4:32 AM
BroFar
BroFar - avatar
+ 3
= is assignment, not comparison R does not use "or" if you want to find the nth root of a number, you can calculate it as num^(1/nth) if you take the nth root as integer (e.g. 2 instead of "square root"), you don't need the comparisons but use the number directly have another look at booleans and comparison in R
9th Sep 2022, 6:19 AM
Lisa
Lisa - avatar
+ 3
<- is assignment Read the lesson on booleans and comparisons again edit: Dividing by 3 doesn't give the 3rd root of the number
9th Sep 2022, 8:59 AM
Lisa
Lisa - avatar
+ 3
Do you understand what booleans are?
9th Sep 2022, 9:18 AM
Lisa
Lisa - avatar
+ 3
What you probably want to do is the following: if (1st input == "square root" || 1st input == "Square root" ...) If (at least) one of the sub-statements evaluates to TRUE, you calculate the square root.
9th Sep 2022, 9:21 AM
Lisa
Lisa - avatar
+ 3
You want to compare strings i the if-statement? But you convert the 1st input to a number in line 3?
9th Sep 2022, 9:31 AM
Lisa
Lisa - avatar
+ 3
If f is an integer, it is a number like 1 or 2 or 3... How would it this number ever be equal to "square root"?
9th Sep 2022, 9:38 AM
Lisa
Lisa - avatar
+ 3
Compare: f == "square root" == True (wrong) f == "square root" (correct)
9th Sep 2022, 9:50 AM
Lisa
Lisa - avatar
+ 2
Then you shouldn't convert the 1st input to integer but leave it as string...
9th Sep 2022, 5:26 PM
Lisa
Lisa - avatar
+ 2
🔥🅳🅴🆅 🅼🅸🆂🅷🆁🅰🔥 I believe this is what you are looking for as one readLines input appeared as it was actually not working. This still takes both inputs The first as a string The second as a numeric https://code.sololearn.com/cdoimXH1Cm5b/?ref=app
9th Sep 2022, 10:23 PM
BroFar
BroFar - avatar
+ 1
Hi
10th Sep 2022, 3:30 PM
Nikhil Singh
Nikhil Singh - avatar
+ 1
I can do not understand in any basic html tag... Please help me so i request...😣😞💔
11th Sep 2022, 2:38 AM
GOPAL MADANE
GOPAL MADANE - avatar