0

Why can’t a string be used for this?

So here’s the code to reverse a string. Why is a string the wrong data type? https://code.sololearn.com/c0eUPG2ry7MN/?ref=app

11th Aug 2022, 10:48 AM
StrWrsBoi
StrWrsBoi - avatar
1 Respuesta
+ 3
If your string has a length of 5, then the max index will be 4. So you would need to start at str.length-1 to count down
11th Aug 2022, 10:53 AM
Lisa
Lisa - avatar