+ 1

How to solve that?

At the last part from line 57-60. It showing some different type output where it should shown a reverse text of a tuple. So, I need a solution. The code is— https://code.sololearn.com/c3cKEgdtazs7/?ref=app

24th Nov 2022, 2:59 AM
Mustakim Rahman
Mustakim Rahman - avatar
6 Answers
+ 5
Mustakim Rahman , Ipang , converting a string or a reversed string to a tuple has some pitfalls, as you can see in the samples and results. to get an expected result, we have to use a trailing comma. have look at the samples and results in the attached file: https://code.sololearn.com/cuIh6U72X2jc/?ref=app
24th Nov 2022, 8:11 PM
Lothar
Lothar - avatar
+ 3
Is there a particular purpose of wrapping the string in a `tuple` that you can't simply reverse the string? t = ( "Pyhon" ) is not a tuple. It's still a string. t = ( "Python", ) is a tuple
24th Nov 2022, 3:38 AM
Ipang
+ 2
but brother adding t=("python") to that code is still showing different types output..!
24th Nov 2022, 5:20 AM
Mustakim Rahman
Mustakim Rahman - avatar
+ 2
Mustakim Rahman your code suffers from bad variable naming. In the top part, you used tuple, str and list as variable names.You should not do this, because they are reserved keywords That is why you are unable to use them as functions later on, so you get errors. Rename the variables tuple1, str1, list1, list2. Sololearn does not have linting helper that warns you of these problems.
26th Nov 2022, 1:24 AM
Bob_Li
Bob_Li - avatar
+ 1
still not solved yet!
24th Nov 2022, 5:28 AM
Mustakim Rahman
Mustakim Rahman - avatar
0
# create a `tuple` from string "python" t = tuple( "python" ) # reversed() returns a `reversed` object # so we need to convert it back to a `tuple` y = tuple( reversed( t ) ) # now we have a reversed `tuple` print( f"{y = }\n<y> is a {type( y )}" )
24th Nov 2022, 9:31 AM
Ipang