Tabs in Multiline Strings

For multiline strings, is there a way to use tab spaces for a table-like format?

I’m unable to do the following for the Pokedex exercise (only shows up as normal non-breaking space in printout): …

print("""
      Pokedex Number: [tab here] \(num), 
      Name: [tab here] \(name), 
      Type: [tab here] \(type), 
      Abilities: [tab here] \(ability). 
    """)

Hello! Consider using the \t (tab) character:

print("something\tsomethingelse")
//will print: something       somethingelse

Alternatively, since you are using multi-line strings, you can simply use the tab key on your keyboard:

print("""
something    somethingelse
"""
#this should print: something    somethingelse

I hope this helps!

1 Like

Thank you! I didn’t realize that the /t character could be used in Swift like that.

1 Like