Question: I am trying to make an app that takes inputed string and then separates every character by space, and finally show it. For example, when I input "pizza" it should output "p i z z a". Unfortunately, the following code, which I wrote, does not work:

```
@IBOutlet var input: UITextField!

@IBOutlet var output: UITextField!

@IBAction func split(sender: AnyObject) {

```

I think the problem lies in the following for-in:

```
    for character in input.text!.characters.indices {

        input.text = String(input.text![character], terminator: "")

        }

        output.text = input.text

}

```

I am new to programming and I was trying to find the solution on the web, but I did not manage to. Could you help me?

Answer: 
You can create an array of your string characters and use joinWithSeparator to join it with a space:

```
extension String {
    var spacedString: String {
        return characters.map{String($0)}.joinWithSeparator(" ")
    }
}

"pizza".spacedString

```
You make three mistakes here:

1) You are assigning new value to `input.text` every time in the loop, not append to the end of the result string.

2) You loop thru the `input.text` and at the same time, you are changing the value inside `input.text` which causes some problem when doing `input.text![character]`

3) You don't need to use `String(input.text![character], terminator: "")`. `"\(input.text![character]) "` should work well

Leo Dabus's answer should work for you but I also want to provide a lower level version:

```
var result = String()

for character in input.text!.characters {
    result.appendContentsOf("\(character) ")
}

output.text = result.stringByTrimmingCharactersInSet(.whitespaceAndNewlineCharacterSet())

```