+ 1
Hovercraft challenge
I have a coding challenge requiring an input, but I am coding in Swift. Unlike Python which has an input() function, I dont have that pleasure. Any help on how I could resolve this?
10 Antworten
+ 5
Try this
monthly(customers: Int(readLine()!)!)
+ 3
Yeah, you're correct.
readLine function gives an optional.
The exclamation mark is used to forcefully unwrap the optional :)
+ 1
Show your attempt
+ 1
Steven try the readLine function
+ 1
Simba Thank you so much! Would you mind explaining how this works? My understanding is that “!” Unwraps the optional and forces the code to accept the inputted value, is that correct?
+ 1
Dear Steven Take reference from here : https://code.sololearn.com/cSW9Zn6u23iV/?ref=app.
Happy CODING!!!
+ 1
Anurag Saikia Simba helped me solve it, but thank you
0
Matiyas
https://code.sololearn.com/c70VsMuObx4v/?ref=app
Sorry about that
0
inxanedev! I tried using that when I called the function and it failed every test
Ex.
Monthly(customers: readLine())
0
inxanedev! I have also tried
Ex.
Monthly(readLine())
And it fails each test