It depends somewhat on what approach you take. But I'll try to unravel it a bit. Basically, an electric car is significantly more energy-efficient; 80% are actually used. On the other hand, combustion engines are said to be 30-40% efficient.
Some say: The internal combustion engine is consciously called the internal combustion engine and not a moving machine.
The question is always how much of the energy used can actually be used for moving and how little energiie is simply "lost" as heat. Or to put it another way: The question is always how much of the energy used actually gets onto the road.
For example an approach:
Petrol has a calorific value of approx. 8.6 kWh / liter. The smart needs 15-17 kWh / 100 km, i.e. approx. 2 liters, if you could use 100% of the energy from the gasoline for driving. (Certainly there are also some here that can drive it more economically. But the numbers used are my numbers)
The following simplified formula would be suitable for your question:
[Consumption in kWh]: 8.6 kWh / liter = [converted petrol consumption in liters]
17 kWh: 8.6 kWh = 1.97 L
.. that's how people come up with statements like "An electric car only needs 2 liters of fuel".
If we spin this formula further and include the above mentioned 30-40%, as well as 80%, then we calculate as follows:
17 kWh x 0.80 = 13.6 kWh (net electricity consumption - electric car)
8.6 kWh x 0.35 = 3.01 kWh (net energy consumption - petrol car)
(17 kWh / 100 km) : (3.01 kWh / 10 km) = 5.7 liters per 100 km
.. if we assume that an electric car needs 17 kWh per 100 km, then with a petrol engine it would need 5.7 liters per 100 km. (The 17 kWh is an empirical value from me, the smart needs a lot because it is not particularly streamlined. For example, a Tesla Model 3 only needs 10-15 kWh with the same driving style, but we don't go down this rabbit hole now .. )
But the question is usually not about energy efficiency, because we don't see that in our wallets. The question is about the cost of electricity. You can calculate that as follows:
[Consumption over 100 km in [kWh or liter]] x [Energy costs in [kWh or liter]] = Energy costs in [kWh or liter] over 100 km
.. so for example:
(17 kWh / 100 km) x (0.30 € / kWh) = 5.10 € per 100 km
(5.7 liters / 100 km) x (1.45 € / liter) = 8.26 € per 100 km
Of course, you can still argue in detail about whether the kWh and liter prices are correct or are assumed to be too high / too low. I recommend everyone to see for themselves what they pay for electricity at home, or what gasoline costs at the local gas station.
Hope I was able to get that across in an understandable way.