Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Quereact Latest Questions

Hi I have two lists list1 and list2 I want to extract all values that exist in list1 and don’t exist in list2. I tried this code: Read more

  1. You can simly use a for loop with append to list. list1 = ['lion', 'dog', 'cat', 'tiger', 'cat', 'cat', 'zebra'] list2 = ['monkey', 'tiger', 'cow', 'mouse'] my_list = [] for animal in list1: #iterating over list1 if animal not in list2 and animal not in my_list: my_list.append(animal) #add item to tRead more

    You can simly use a for loop with append to list.
    [crayon-6763ee9dae300746838803/]
    [crayon-6763ee9dae303968517914/]
     

    kind regards

    See less
0
0
Be the first one react

Hi I have a variables that is declared outsides fucntions. How can I use and change these variables inside function usign Python? thank you

  1. Follow this example to create a variable outside functions, and use it inside the functions: MyVariable = 99 #this is a global variable def changeAndPrint_GlobalVariable(): global MyVariable #use global variable in this function with "global" keyword print('Global variable "MyVariable" before changeRead more

    Follow this example to create a variable outside functions, and use it inside the functions:
    [crayon-6763ee9dae460964846212/]
    This code will print:
    [crayon-6763ee9dae462629665829/]
     

    See less
0
0
Like1 User
1 User

Hi, I want to convert a list using python. I have a list of list like this: Read more

  1. Hello this code may help you: def flatten_list(original_List): flat_list = [] for sub_list in original_List: for element in sub_list: flat_list.append(element) return flat_list #test original_List=[['a', 'b', 'c', 'd','e'], ['f', 'g', 'h', 'i'], ['j', 'k', 'l'], ['m', 'n', 'o']] print('original listRead more

    Hello

    this code may help you:
    [crayon-6763ee9dae5e1443086783/]

     

    See less
0
0
Like1 User
1 User

I have a list which contain names of students. Example: Read more

  1. You can use Counter if you want to do multiple count of the list from collections import Counter list = ['Jones','Adams','Frank','John','Lopez','Jones','Smith','Ivan','Julian','Carlos','Adams','Frank','Jones','John','Ivan'] print(Counter(list)) Result: Counter({'Jones': 3, 'Adams': 2, 'Frank': 2, 'JRead more

    You can use Counter if you want to do multiple count of the list
    [crayon-6763ee9dae14a240070058/]
    Result:
    [crayon-6763ee9dae14d013692789/]
     

    See less
0
0
Be the first one react