Tag Archives: Python
Iterating over a custom ‘Jagged Array’ in Python
A jagged array is an array whose elements are arrays. The elements of a jagged array can be of different dimensions and sizes. A jagged array is sometimes called an "array of arrays." C# natively differentiates between a jagged and a multidimensional array. To iterate over a every single element of a Jagged Array in […]
read(), readline(), readlines() & xreadlines() func in Python
While doing a regression analysis, I had to read & parse through a large .dat file. I called readline() func but was surprised to see that I was actually iterating through every single character in the first line! with open(filePath, ‘r’) as f: for line in f.readline(): print line Then realization dawned upon me! * […]
Convert vowels to uppercase in a string
Given a string – say “hello world”, I was interested in capitalizing the vowels in it – IN A CLEAN & EFFICIENT WAY! In the first approach, I use a StringBuilder object to hold the intermediate String while in the second approach, I’m using a C# feature – Linq. In the second approach, there is […]
Login