Artificial neural networks (ANNs) have recently also been applied to solve partial differential equations (PDEs). In this work, the classical problem of pricing European and American financial options, based on the corresponding PDE formulations, is studied. Instead of using numerical techniques based on finite element or difference methods, we address the problem using ANNs in the context of unsupervised learning. As a result, the ANN learns the option values for all possible underlying stock values at future time points, based on the minimization of a suitable loss function. For the European option, we solve the linear Black-Scholes equation, whereas for the American option, we solve the linear complementarity problem formulation. Two-asset exotic option values are also computed, since ANNs enable the accurate valuation of high-dimensional options. The resulting errors of the ANN approach are assessed by comparing to the analytic option values or to numerical reference solutions (for American options, computed by finite elements).