Finding elements not in list

Haloo people! How long has it been since I’ve done a blog post? Welp, I’ve finished my long break and now it’s time to get back to work. Today, I’ll be writing a python program that prints the elements of one list (a) that are not in the other list (b) as a list. My conditions are: If the lists have the same elements, it will print an empty list. If the first list (a) is an empty list, it’ll print an empty list. An example - ...

February 4, 2024 · 2 min · SourFox

Assignment 5: Elements and Indices

Today I had to do another assignment which is to create a python program which prints the elements of a list followed by their corresponding indices. Each element and its index must be on the same line seperated by a space. And if the list is empty, print “Empty List”. I’m going to make a list called num and put 1 to 4 inside. num = [1, 2, 3, 4] Then I’ll use the if statement to do: ...

November 11, 2023 · 2 min · SourFox

Assignment 3: Doubling

Today, I was given another assignment. (Which I wasn’t expecting.) Today’s assignment was to write a python program which had to meet the conditions: Write a Python proram that multiplies all the items in a list by the value of the variable factor. The program must print the list as the output. The program should allow multiplying the variable factor by a string in case the list contains strings. You may assume that the value of factor will be a positive integer. ...

October 18, 2023 · 4 min · SourFox

Assignment 1: Using Length and String

Today, I was given an assignment. My assignment wanted me to write a Python program that pints the length of a string. This is what I had to print out: The length of "" is 0. The length of "H" is 1. The length of "Hello" is 5. The length of "Amazing" is 7. To do this, I have a plan in my mind which is: Step 1. Find out what I’m going to use. ...

October 15, 2023 · 3 min · Soure Fox