+ 2

friends, what is wrong with this?(I need to add the taken string to the list as a new field called "id", and output the result)

str <- readLines('stdin') x <- list("name"="James", "age"=42, "country"="USA") y <- list("id"="1-2-3") z<- c(x, y) print(z)

19th Oct 2021, 3:27 PM
Tree
Tree - avatar
3 Antworten
+ 2
1. You aren't using the input. You assign it to a variable, but never use the variable. 2. Where does the value "1-2-3" come from that you assign to "id"? That's probably where you should use the variable str.
19th Oct 2021, 4:47 PM
Simon Sauter
Simon Sauter - avatar
+ 1
now it's correct: str <- readLines('stdin') x <- list("name"="James", "age"=42, "country"="USA") list <- c(x,"id"=str) print(list)
19th Oct 2021, 6:19 PM
Tree
Tree - avatar
+ 1
Dankeschön :)
19th Oct 2021, 6:31 PM
Tree
Tree - avatar