When drive car lose power but dont cut off. It goes into a loping idle. on 2002 Nissan Sentra

Cranks good, idle good, but when drive lose power, goes into low idle no power, but don't stall.

1 answer
scan codes and post so we can adv,could be crank sensor or other issues