u need to make a program that takes a US state code as input and outputs its full name. Where is the error? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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)

12th Sep 2021, 8:01 PM
Ammara Tayyab
9 Answers
+ 6
The commas in the switch are missing. And print the result instead of x :)
12th Sep 2021, 8:21 PM
Lisa
Lisa - avatar
+ 2
Can you please link your code?
12th Sep 2021, 8:05 PM
Lisa
Lisa - avatar
+ 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)
12th Sep 2021, 8:22 PM
mesarthim
mesarthim - avatar
+ 1
Please show your attempt and specify your actual problem. Happy coding!
12th Sep 2021, 8:06 PM
mesarthim
mesarthim - avatar
+ 1
What is your question? This sounds like a challenge. If so, please show us your attempted
12th Sep 2021, 8:06 PM
Brain & Bones
Brain & Bones - avatar
+ 1
Thank you mesarthim
12th Sep 2021, 8:26 PM
Ammara Tayyab
+ 1
input <- readLines('stdin') x<-input[1] result<- switch ( x, "CA "= "California", "NY "= "New York", "FL "="Florida", "OH "= "Ohio" ) print(result)
8th Sep 2022, 3:56 AM
Vaishnavi Mani
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
12th Sep 2021, 8:19 PM
Ammara Tayyab
0
state <- readLines('stdin') x <- state result <- switch( x, "CA" = "California", "NY" = "New York", "FL" = "Florida", "OH" = "Ohio" ) print(result)
17th Jan 2022, 2:40 PM
Leila Bouchiba
Leila Bouchiba - avatar