How to print the last let us say 10 elements of an array containing 50 ekements ?
The code in python 3:
x = [‘a’,’b’,’c’,’d’,’e’,’f’,’g’]
n = 5
y =[ ]
i = 0
while (i<n) :
i+=1;
y.append(x[-i])
print(y)
Simple !
Note : index of -1 gives last element of an array
hope you dont mind the fig version:
LikeLiked by 1 person
Can you recommend with one after the other new line?
LikeLike
“recommend with one after the other new line”
im not sure…
which line is “the other new line”?
and can you say “recommend” in a different way, maybe i will know what you mean then.
🙂
LikeLiked by 1 person
“quotes go in strings”
# hashes for comments
p = 5.5 # this works
p = 5.str # NO
p = y.str # yes 🙂
p = (5).str # yes 🙂
p = 5 str # yes 🙂
p 5 str # yes 🙂
these are optional– only use when you want to ( ) | : ; , =
cheatsheet: https://codeinfig.wordpress.com/2016/02/11/fig-command-cheat-sheet/
book: https://codeinfig.files.wordpress.com/2016/05/figbook10chdraft.pdf
source: https://codeinfig.wordpress.com/2016/02/10/fig-3-1-source-code-public-domain/
**if you have windows**, fig needs colorama: https://pypi.python.org/pypi/colorama/0.3.2
LikeLiked by 1 person
very very good
LikeLiked by 1 person
ok
rewent through, really nice!!!
LikeLiked by 1 person
no it’s ok mobile display bit crazy
LikeLike
it cant zoom in and zoom out on the app for wordpress?
LikeLiked by 1 person
Fig syntax nice. Where is the ref?
LikeLiked by 1 person
you may try this also:
x = [‘first’, ‘second’, ‘secondlast’, ‘last’]
n = 2
x[-n:]
LikeLiked by 1 person
yep good
me i showed a universal / cross language solution
LikeLike