import Foundation
func removeLastChar(_ s: String?) -> String? {
guard let s = s, !s.isEmpty else {
return nil
}
return String(s.dropLast())
}
var s: String? = "swift java c c++ python"
s = removeLastChar(s)
print(s ?? "nil")
/*
run:
swift java c c++ pytho
*/