To find the cost per gallon of gas, you can divide the total amount spent by the number of gallons:
\[ \text{Cost per gallon} = \frac{\text{Total amount spent}}{\text{Number of gallons}} = \frac{42}{12} \]
Calculating that:
\[ \frac{42}{12} = 3.50 \]
So, Safira spends $3.50 per gallon of gas.