Find how many numbers two numbers have in common

So I’m trying to make a program that tells the user how many numbers both inputted numbers have in common FOR EXAMPLE: if inputted n1 = 765 and n2 = 572 then the program returns 2 because both numbers …

How to iterate over a list once only in a nested loop in Python

I intend to send message to many numbers, but this is my code and issue (code is made shorter and required lines are here): msg = ‘test message’ phone_numbers = [‘+989111111111’, ‘+989111111112’, ‘+…

How to replace equal consecutive numbers in a list to nan?

I’m trying to replace equal consecutive numbers in a list to nan. I having problems to replace all values when there is a odd number of equal consecutive numbers. This is my code, very simple: list= […

Moving specific number (without sort) to the left of list

I want to just move the zero’s to left and don’t want to sort the list. For example, if my list is like: nums = [1, 10, 20, 0, 59, 63, 0, 8, 0] Here’s the output which I desire after moving all the …

Creating list of dictionaries from a dictionary using list comprehension

I have a dictionary of the format: d = {‘award1’ : { ‘nominees’: [‘name1’, ‘name2’], ‘presenters’: [‘name3’, ‘name4’], ‘winner’ : ‘name1’ } ‘…

Modifying the contents of a list Python

Here’s the coursera Google question prompt that I’m having issues with: The skip_elements function returns a list containing every other element from an input list, starting with the first element. …

print/list only 5 entries from OS.Walk in python

My Goal – To list only 5 entries when using OS walk. So far I have only been able to get a list of everything that I find using OS.Walk or only list one entry. (By using the return function) My code: …

Finding all the elements in a list between two elements (not using index, and with wrap around)

I’m trying to figure out a way to find all the elements that appear between two list elements (inclusive) – but to do it without reference to position, and instead with reference to the elements …

How to refence entries with a certain value within a list in python

I am getting data from database and storing it in a list called relays. this list currently looks like this: relay: [(4, ’26’, ’19’), (5, ’13’, ‘6’)] the first number of each item is the id number …

Python long list is broken into annoying multiple line in VScode?

enter image description here Hi, I am using VScode for python. I face an annoying point in autoformat that a long list is broken into multiple lines as shown in the picture. I try to change wordwrap …