User input in type Double

Hey guys, hope you can help me
If I use readLine() I can get users input
But I can’t do anything in math with it cause this input is in the String type. What I gotta do if I need users input for “Double” data type

UPD: Double() doesn’t work

The readLine function returns an optional string, because there might not be any text to read. You need to unwrap it to a string first, with something like if let or guard let.

Then, once you have a string, you can attempt to initialize a Double from it. The result is another optional, because the string might not actually represent a double. So you have to unwrap it, again using if let or guard let.