Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS Functions in Swift Adding Power to Functions Returning Complex Values

Functions in Swift Challenge: Return a complex value

My code works in a playground, but I get a non-specific error message. When I click on preview to see the errors, the output is empty. What am I missing?

// Enter your code below
func coordinates(for location: String) -> (Double, Double) {

    var lat: Double = 0.00
    var lon: Double = 0.00

    switch location {
    case "Eiffel Tower":
        (lat = 48.8582, lon = 2.2945)
    case "Great Pyramid":
        (lat = 29.972, lon = 31.1344)
    case "Sydney Opera House":
        (lat = 3.8587, lon = 151.2140)
    return (lat, lon)
coordinates(for: "Eiffel Tower")

3 Answers

Jennifer Nordell
Jennifer Nordell
Treehouse Teacher

Hi there! You're actually doing fantastic. The problem here is simply a pair of typos. The latitude for "Sydney Opera House" and "Great Pyramid" are incorrect, so it's getting back a faulty latitude.

The latitude for "Sydney Opera House" is supposed to be 33.8587 but you typed 3.8587. Note the missing 3 at the beginning. On the "Great Pyramid", the latitude should be 29.9792 but you typed 29.972. Note the missing 9 towards the end between the 7 and 2.

No problems here besides a couple of typos and that happens to those who think faster than they type :smiley:

Hope this helps! :sparkles:

Yes, very good advice: I need to slow down some times. It works perfectly now. Thanks for the quick response, Jennifer!

1,142 Points

Thanks for posting this , although this is not part of the challenge I want to know how you can make the code non sensitive to both Upper Case and Lower Case when the user writing the input.