Posts Tagged ‘end’

Exit command in R

Posted: 26th April 2015 by Tim in R
Tags: , , , , , ,

R is quite different from most other programming languages. One common feature of other languages is the exit routine, or something with a similar name. In R, that function is stop, and takes an error message string as an argument. For example: stop(“I don’t work on weekends”) will print: Error: I don’t work on weekends […]

Reversing a string in Python

Posted: 25th April 2013 by Tim in Python
Tags: , , , , , , , ,

If you need to reverse a string in python, the easiest way is to do use the my_string[::-1] syntax. For example, to print a reversed string, you could write: my_string = “ABCDE” print my_string[::-1] So what is this doing? The square bracket syntax is used for returning a substring. This works like so: [<start>:<end>:<step>]. If […]