Ask coding questions

← Back to all posts
Why it isn't printing any thing
IshanShrivas05 (0)

plz someone guide me , i'm new to coding and don't know much about it.

Answered by ch1ck3n (2062) [earned 5 cycles]
View Answer
ch1ck3n (2062)

i think this is what you want:

mystr = "barry is a good boy"
IshanShrivas05 (0)

@ch1ck3n no bro , i want it as it is [-1:-18]

ch1ck3n (2062)



you're starting the string at -1, which is already impossible. you also can't stop at -18. so because the string is 19 letters long, my program stops the string at 18 characters. you can't stop string at -18 characters. it also starts at 1 characters. so it basically skips the first letter and remoes the last character.

xxpertHacker (930)

@ch1ck3n Doesn't slicing by negatives in Python wrap around to the end?

ch1ck3n (2062)

@xxpertHacker Indexing does but slicing doesn't in this case

IshanShrivas05 (0)

@ch1ck3n Now I got it bro....thankuuu:)

ch1ck3n (2062)

@IshanShrivas05 can you click the checkmark next to my name if it helped? thank you!

ch1ck3n (2062)

What do you want your code to do?