code not working

I cant get this code to execute but it works fine without the key press any way to fix this

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Player : MonoBehaviour
public InventoryObject inventory;

public void OnTriggerStay(Collider other)
    var item = other.GetComponent<Item>();
    if(item && Input.GetKeyDown(KeyCode.E))
        inventory.AddItem(item.item, 1);



@agentX900 Change to

if(item != null && Input.GetKeyDown(KeyCode.E))

it’s unclear what just testing if(item) will return - and I suspect for that reason the && operator isn’t working.