Can anyone enlighten me about slicing in python and how it's used? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Can anyone enlighten me about slicing in python and how it's used?

5th Oct 2018, 1:37 PM
partha
partha - avatar
6 Answers
+ 2
5th Oct 2018, 4:01 PM
Maninder $ingh
Maninder $ingh - avatar
+ 2
No, no, it is perfectly reasonable, when you start a program, to expect that it either does stuff or tells you what it needs and not just fail. It's only that it's hard to do here. After a while you get used to it...
6th Oct 2018, 10:06 AM
HonFu
HonFu - avatar
+ 1
And after you've done that, if you want to look at some practical applications, I'd be happy if you took a look at my examples. :-) (If something is confusing, please ask.) https://code.sololearn.com/c36892iW8Srd/?ref=app https://code.sololearn.com/cJPmTf5bW1la/?ref=app https://code.sololearn.com/cOgBIKfp377h/?ref=app
5th Oct 2018, 10:21 PM
HonFu
HonFu - avatar
+ 1
HonFu your codes looks awesome but at the moment I'm not able to understand them much but I'll check them later for sure when I'll catch up.😀 and the third code (owl matrix asserter) is showing error
6th Oct 2018, 12:43 AM
partha
partha - avatar
+ 1
partha, the error happens because the program expects you to do a special kind of input first. Unfortunately we have no real way here to interact with the user (except in web programming), so we can only explain in a comment, how it works. I have changed other scripts in order that if you don't input anything, there's a default data set. Mostly I don't use inputs anymore and let people enter directly in the code instead. About my codes: You can move through a slice in so many ways (startpoint, endpoint, direction, stepwidth) that you can do a lot of stuff with it, like move within a geometrical shape like a square or a cube. Mostly squares get modelled using two values for a point (x and y), but with Python slices you can just write a long list of numbers and make it behave like a square or a cube - so I was having a bit of fun doing exactly that. ;-)
6th Oct 2018, 9:54 AM
HonFu
HonFu - avatar
+ 1
oops sorry then HonFu it's my lack of knowledge 😔
6th Oct 2018, 10:01 AM
partha
partha - avatar