-4
import UIKit

var str = "Hello, playground"  
let NumberofStopLights: Int = 4 
var population: Int 
population = 5000 
let TownName = "HappyPlace"
let TownDescription = return "/(TownName) has a population of /(population) and /(numberofStopLights) Stop Lights 
print (TownDescription)

I want to have the integers automatically go into the /(TownName), /(population) and /(numberStopLights) spaces, tried using the return function but it did not work. SO..... I tried doing this based off another post on Stack Overflow, which said to put return right in front of it but that did not work, so... what next? (Code above)

rmaddy
  • 314,917
  • 42
  • 532
  • 579
  • I'm not sure that this code even compile. `let TownDescription = "\(TownName) has a population of \(population) and \(numberofStopLights) Stop Lights`". It's missing the closing double quote, the slashes are not in the good orientation (use back slash: `\` instead of `/` before your var between parenthesis) and I don't know what means the `return` at the beginning. Also name all your var starting with a lowercase. – Larme Dec 05 '17 at 20:35
  • Did you make any attempt to look at [the duplicate I linked](https://stackoverflow.com/questions/24646794/concatenate-number-with-string-in-swift) on your [previous question](https://stackoverflow.com/questions/47646357/return-function-not-working-when-attempting-to-get-swift-to-draw-from-integers)? – rmaddy Dec 05 '17 at 20:39
  • Yeah, it did not help and or work – NinjaFangGames Dec 05 '17 at 20:51

1 Answers1

2

You don't need the return, also your interpolation is wrong. Should be \() instead of /() and you forgot the last " when declaring your Townname string.

var str = "Hello, playground"
let NumberofStopLights: Int = 4
var population: Int
population = 5000
let TownName = "HappyPlace"
let TownDescription = "\(TownName) has a population of \(population) and \(NumberofStopLights) Stop Lights"
print (TownDescription)

You should also try to use upper and lowercase the correct way, although the compiler doesn't care, but it will make your life a lot easier in the end!