题解 | #字符串反转#
字符串反转
https://www.nowcoder.com/practice/e45e078701ab4e4cb49393ae30f1bb04
golang 版本
package main import ( "fmt" ) func main() { a := "" n, _ := fmt.Scan(&a) if n == 0 { return } else { res := "" for i := len(a) - 1; i > -1; i-- { res += fmt.Sprintf("%c", a[i]) } fmt.Println(res) } }
python版本
scan = input() res = "" for i in range(len(scan) -1, -1, -1): res += scan[i] print(res)