The function 'reverse' takes one parameter. Return the reversed parameter.
The parameter can be either an int or a string, and your return must be of the same type as the input.
reverse(1234) --> 4321
reverse('absfe') --> 'efsba'
def reverse(intOrStr):
reversed = ''
ss = ''
if str(intOrStr) == intOrStr:
for i in range(len(intOrStr)):
reversed += intOrStr[len(intOrStr)-i-1]
return reversed
else:
ss = str(intOrStr)
for i in range(len(ss)):
reversed += ss[len(ss)-i-1]
return int(reversed)
test.assert_equals(reverse('aaaaaaabc'), 'cbaaaaaaa')
test.assert_equals(reverse('320947873434169728465327'), '723564827961434378749023')
test.assert_equals(reverse('fghrefudjfhigufdhjkbehiwgyd87v9sfiehufgydufehwgfdyvsegrt78eyt8fguyrv78fgd4irv78fhyrv...fg. . , .dfs,defehfegruekfhdgu'), 'ugdhfkeurgefhefed,sfd. , . .gf...vryhf87vri4dgf87vryugf8tye87trgesvydfgwhefudygfuheifs9v78dygwihebkjhdfugihfjduferhgf')
test.assert_equals(reverse(''), '')
test.assert_equals(reverse(12355), 55321)
test.assert_equals(reverse(23465782465328241973852672384973586273243582698734362097432849367832374386957374806395762387362975342748369274534783629743), 34792638743547296384724357926378326759360847375968347323876394823479026343789628534237268537948327625837914282356428756432)