home.social

#pythonquestion — Public Fediverse posts

Live and recent posts from across the Fediverse tagged #pythonquestion, aggregated by home.social.

fetched live
  1. Python Question: Is there an efficient way to see if every element in an iterable is equal to a user-specified value?

    The best idea I've seen so far is to use a list comprehension to check for equality, and then use the all function, like this:
    MyList = [1,1,1,1,1,1,1]
    all((x==1 for x in MyList))

    That's readable and probably not bad performance. Is there something better?

    #Python #PythonQuestion

  2. Python Question: Is there an efficient way to see if every element in an iterable is equal to a user-specified value?

    The best idea I've seen so far is to use a list comprehension to check for equality, and then use the all function, like this:
    MyList = [1,1,1,1,1,1,1]
    all((x==1 for x in MyList))

    That's readable and probably not bad performance. Is there something better?

    #Python #PythonQuestion

  3. Python Question: Is there an efficient way to see if every element in an iterable is equal to a user-specified value?

    The best idea I've seen so far is to use a list comprehension to check for equality, and then use the all function, like this:
    MyList = [1,1,1,1,1,1,1]
    all((x==1 for x in MyList))

    That's readable and probably not bad performance. Is there something better?

    #Python #PythonQuestion

  4. Python Question: Is there an efficient way to see if every element in an iterable is equal to a user-specified value?

    The best idea I've seen so far is to use a list comprehension to check for equality, and then use the all function, like this:
    MyList = [1,1,1,1,1,1,1]
    all((x==1 for x in MyList))

    That's readable and probably not bad performance. Is there something better?

    #Python #PythonQuestion

  5. Python quiz

    What is the result

    A. Invalid syntax, should use 'if' for condition
    B. [80,73,82,64]
    C. [True, True, True, True, False]
    D. [80]

    #pythonquestion #python #python3 #pythonquiz #programmers

  6. Python quiz

    What is the result

    A. Invalid syntax, should use 'if' for condition
    B. [80,73,82,64]
    C. [True, True, True, True, False]
    D. [80]

    #pythonquestion #python #python3 #pythonquiz #programmers

  7. Python quiz

    What is the result

    A. Invalid syntax, should use 'if' for condition
    B. [80,73,82,64]
    C. [True, True, True, True, False]
    D. [80]

    #pythonquestion #python #python3 #pythonquiz #programmers

  8. Python quiz

    What is the result

    A. Invalid syntax, should use 'if' for condition
    B. [80,73,82,64]
    C. [True, True, True, True, False]
    D. [80]