Row count where data exists

If you need VBA, you could do something quick like this: This will print the number of the last row with data in it. Obviously don’t need MsgBox in there if you’re using it for some other purpose, but lastRow will become that value nonetheless.

range() for floats

As the comments mention, this could produce unpredictable results like: To get the expected result, you can use one of the other answers in this question, or as @Tadhg mentioned, you can use decimal.Decimal as the jump argument. Make sure to initialize it with a string rather than a float. Or even: And then: [editor’s not: if you only … Read more

Pop index out of range

To get the final value of a list pop’ed, you can do it this way: Keep in mind that pop removes the item, and the list changes length after the pop. Use negative numbers to index from the end of a list that may be changing in size, or just use pop() with no arguments for the … Read more

How does String substring work in Swift

All of the following examples use Swift 4 Strings got a pretty big overhaul in Swift 4. When you get some substring from a String now, you get a Substring type back rather than a String. Why is this? Strings are value types in Swift. That means if you use one String to make a new one, then … Read more

Print a list in reverse order with range()?

use reversed() function: It’s much more meaningful. Update: If you want it to be a list (as btk pointed out): Update: If you want to use only range to achieve the same result, you can use all its parameters. range(start, stop, step) For example, to generate a list [5,4,3,2,1,0], you can use the following: It may be less intuitive but as … Read more