我想在Python 3.4.2中编写一个代码,它接受一串数字,将它们分开,然后按相反的顺序排列。到目前为止,我有:
#input string
numberIntegers = 123456
#assign each character to an idex
zeroDigit = numberIntegers[0]
oneDigit = numberIntegers[1]
secondDigit = numberIntegers[2]
thirdDigit = numberIntegers[3]
fourthDigit = numberIntegers[4]
fifthDigit = numberIntegers[5]
print(" The numbers to reverse: {}".format(numberIntegers))
print(" The digits, in order, are: {} {} {} {} {} {}".format(zeroDigit,oneDigit,secondDigit,thirdDigit,fourthDigit,fifthDigit))
print(" The numbers in reverse: ")
答案 0 :(得分:0)
numberIntegers
是一个整数而不是一个字符串。像这样改变:
numberIntegers = '123456'