+ 1
u need to make a program that takes a US state code as input and outputs its full name. Where is the error?
state <- readLines('stdin') x <- state[1] result <- switch( x "CA" = "California" "NY" = "New York" "FL" = "Florida" "OH" = "Ohio" ) print(x)
9 ответов
+ 6
The commas in the switch are missing. And print the result instead of x :)
+ 2
Can you please link your code?
+ 2
You forgot comma at the end of the statements and you should write result, not x.
#print("Happy coding!")
state <- readLines('stdin')
x <- state[1]
result <- switch(
x,
"CA" = "California",
"NY" = "New York",
"FL" = "Florida",
"OH" = "Ohio"
)
print(result)
+ 1
Please show your attempt and specify your actual problem.
Happy coding!
+ 1
What is your question?
This sounds like a challenge. If so, please show us your attempted
+ 1
Thank you mesarthim
+ 1
input <- readLines('stdin')
x<-input[1]
result<- switch (
x,
"CA "= "California",
"NY "= "New York",
"FL "="Florida",
"OH "= "Ohio"
)
print(result)
0
state <- readLines('stdin')
x <- state[1]
result <- switch(
x
"CA" = "California"
"NY" = "New York"
"FL" = "Florida"
"OH" = "Ohio"
)
print(x)
Lisa mesarthim Brain & Bones
0
state <- readLines('stdin')
x <- state
result <- switch(
x,
"CA" = "California",
"NY" = "New York",
"FL" = "Florida",
"OH" = "Ohio"
)
print(result)