0
Jungle Camping - Swift
I’m having some trouble with this code coach. Information about the task is at the beginning of the code. What am I doing wrong and how do I fix it? https://code.sololearn.com/ciP9NRPidEFw/?ref=app
3 ответов
+ 6
Conditional structure problem
1. `elif` is not a valid syntax, it should be `else if`
2. The condition to be evaluated needs to be wrapped in parentheses (apparently this is optional - as shown by @Solo)
if( condition )
{
// code
}
else if( condition )
{
// code
}
else
{
// code
}
Line 34:
Typo in writing string method name dropLast()
(Edited)
+ 4
import Foundation
if let sounds = readLine() {
let array = sounds.components(separatedBy: " ")
var animals = ""
for sound in array {
if sound == "Grr" {
animals += "Lion "
} else if sound == "Rawr" { //debug
animals += "Tiger "
} else if sound == "Ssss" {
animals += "Snake "
} else if sound == "Chirp" {
animals += "Bird "
}
}
print(animals.dropLast()) //debug
}
+ 2
Thank you so much!