How to remove the last character from string in Swift

1 Answer

0 votes
var s = "swift java c++ c python"

print(s)

let substring = s.dropLast()   

print(substring)
 
 
 
  
/*
run:

swift java c++ c python
swift java c++ c pytho
  
*/

 



answered Nov 9, 2020 by avibootz
...