Instead of
list = []
item = input()
list.append(item)
Can I just straight up do:
list.append(input())
Just not wasting the item variable Actually Codeium popped up saying this so just checking facts
Can it work? Detailed explanation
Yes it will work.
The append
method requires a value. The input()
call supplies the value. (If you need more detail, you will need to clarify what you need to be explained.)
The "waste" of a variable is negligible ... unless you are doing this in a recursive method AND the recursion is many calls deep.
However, the code is (arguably) easier to read if you don't use an unnecessary temporary variable there.