Categories
Uncategorized

Counting Vowels in a String – Python

From this project. The Challenge Enter a string and the program counts the number of vowels in the text. For added complexity have it report a sum of each vowel found. The Logic Make a dictionary with the vowels as keys. Then loop through each letter in the string. If it’s a vowel, append it […]

Categories
Uncategorized

Check if Palindrome – Python

Another one of these challenges – this one is just too easy. The Challenge Checks if the string entered by the user is a palindrome. That is that it reads the same forwards as backwards like “racecar” The logic Since palindromes are the same whether they are spelled backwards or not, we can compare the […]

Categories
Uncategorized

Reverse a String – Python

As sad as it may sound, this is how I relax. EDIT: After reading this Reddit post, it seems the correct answer is Inspired by this reddit post, I’ve decided to have a go at some of them. So today I will have a go at reversing a string. The Challenge Enter a string and […]

Categories
Uncategorized

Reading Files – Python

Just a quickie on files and how to read them. To read a file you can use with open(), adding then the path to the file and giving it a name. Then you can read the file using either read() or readlines(). Read() Using read() will mean that the entire file will be read and […]