Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

Hi Thankx for this section. I need more clarification on s1 = s[8:1:-1] print(s1) Output: lroWoll I am unable to get it .
- sradhanjali behera
Hi I have a doubt: string = “Hi There” print (string[-4:-2]) and the output is ‘he’ but shouldn’t the output be ‘eh’? I am unable to understand why the output is showing he
- Kalpit
For the negative count, the end of the string starts from -1 not 0. It is like -4 -3 -2 -1 not -4 -3 -2 -1 0
- Coder
Your idea about reverse a string using a negative value is completely wrong please update this post. What actually happening here is x = ‘H e l l o w o r l d’ -----0 1 2 3 4 5 6 7 8 9 >>> x[8:1:-1] output – ‘ l r o w o l l ‘ -------8 7 6 5 4 3 2 Usually, the second parameter 1 won’t be taken into consideration right. This means if I enter x[1:8], index 8 won’t be sliced right. Similarly, this happens in x[8:1:-1]. So index 1 won’t be sliced. >>> x[-2:-8:-1] output- ‘lrowol’ Here, -2,-3,-4,-5,-6,-7 indexes will be sliced. Conclusion: string[x:y:p] When p x>y and index y won’t be sliced. That’ it!!!
- Kobinarth Panchalingam
TheData = [20, 3, 4,8,12, 99,4, 26 , 4 ] TheData1= TheData [ 0 : len(TheData) : 1 ] def InsertionData (TheData1): for Count in range(0, len(TheData1)): DataToInsert = TheData1(Count) Inserted = 0 Nextvalue = Count - 1 while (Nextvalue >= 0 and Inserted != 1): if DataToInsert < TheData1(Nextvalue): TheData1(Nextvalue + 1) == TheData1(Nextvalue) Nextvalue = Nextvalue -1 TheData1(Nextvalue +1 ) == DataToInsert else: Inserted = 1 def printarray(TheData1): for count in range(0, len(TheData1)): print(TheData1(count) ) print("Array before sorting \n ") printarray(TheData1) InsertionData(TheData1) print(“Array After sorting \n”) printarray(TheData1) Error: Array before sorting Traceback (most recent call last): File “c:\Users\Admin\Desktop\Paper 4 solution.py”, line 26, in printarray(TheData1) File “c:\Users\Admin\Desktop\Paper 4 solution.py”, line 23, in printarray print(TheData1(count) ) TypeError: ‘list’ object is not callable Anyone help how to done slicing in python
- malik