how do you add space in swift?i tried print("\t") but swift seems to ignore the spaces. My code is
var b=1
var a=2
for var i=3;i>=0;i--
{
for var j=a;j>=0;j--
{
print("\t")
}
a--
for var one=1;one<=b;one++
{
print("1")
}
b++
println(" ")
}
I'm just guessing what you are trying to do based on the question and code... Does this do it?
#!/usr/bin/env xcrun swift
for x in 1 ... 4 {
for y in 0 ..< 4 - x {
print(" ")
}
for y in 0 ..< x {
print("1")
}
print("\n")
}
The above code outputs:
1
11
111
1111
The question is confusing, but rest assured in Swift 3, this will print a tab:
print("\t")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With