0

How can I sort alphabetically my program

30th Oct 2019, 4:53 PM
Rahab
11 Answers
+ 1
ok thanks all
5th Nov 2019, 3:37 AM
Rahab
+ 1
okay thanks
5th Nov 2019, 5:14 AM
Rahab
0
This code should help you understand sorting alphabetically. https://code.sololearn.com/W56fsiEFpidN/?ref=app
30th Oct 2019, 8:05 PM
Shawn Gillis
Shawn Gillis - avatar
0
what is the output of this code arr=[1,2,3,4,5,6,7] print(arr[2:5][1:3]) can someone help understand the code please
5th Nov 2019, 3:39 AM
Rahab
0
You need to use another print statement to perform two slices on the array look in the code below: https://code.sololearn.com/c9o5iKqF2oi6/?ref=app You can also Google Python array index slicing or go to the Python documentation and lookup array index slicing to find out all about arrays and slicing in Python. Btw, Good luck learning Python its a great language to start learning with.
5th Nov 2019, 5:11 AM
Shawn Gillis
Shawn Gillis - avatar
0
If you go to that code I posted and play around with it that may help you. But the reason why the first print statement outputs 3 4 5 is because the array goes to 2 and then after the two it cuts a slice and then it goes to 5 and after 5 it cuts another slice. And takes that section of the array out and returns it. The second print statement does the same thing at 1 and 3. After 1 it takes a slice and after three it takes a slice. And it takes that section between the slices out and returns that.
5th Nov 2019, 5:19 AM
Shawn Gillis
Shawn Gillis - avatar
0
Oh, sorry I swear I thought I saw a post that asked if I could explain. But its gone . Well, maybe it will help anyway.
5th Nov 2019, 5:22 AM
Shawn Gillis
Shawn Gillis - avatar
0
👍
5th Nov 2019, 5:25 AM
Rahab
0
Sorry that code was outputting 3,4,6 on the first print statement because I forgot to put a 5 in the array but I fixed it so its outputting 3,4,5 now.
5th Nov 2019, 5:30 AM
Shawn Gillis
Shawn Gillis - avatar
0
Thats what happens when you get in a hurry and don't check to see if the output is what you expected
5th Nov 2019, 5:33 AM
Shawn Gillis
Shawn Gillis - avatar