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

29th Apr 2023, 3:34 PM
Lashana Jegatheswaran
3 Réponses
+ 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)
29th Apr 2023, 4:02 PM
Ipang
+ 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 }
29th Apr 2023, 9:34 PM
Solo
Solo - avatar
+ 2
Thank you so much!
30th Apr 2023, 3:44 AM
Lashana Jegatheswaran