Tyler Perry's Halloween comedy has retained the top spot at the US box office - holding off competition from Tom Hanks's latest film Inferno.

Boo! A Madea Halloween, which Perry directed, wrote, co-produced and stars in, took $16.7m (£13.7m) on its second weekend of release.

Inferno, based on the Dan Brown novel, scored a relatively disappointing $15m (£12.3m) to debut in second place.

The latest film in the Da Vinci Code series has received poor reviews.

The previous film in the franchise, Angels & Demons, had a considerably more successful opening weekend in 2009 - taking $46.1m (£37.8m).

A senior executive at Sony Pictures, which produced the film, said the figure was partly down to fewer people in the US going to the cinema over the weekend because of two baseball games which drew huge television audiences.

Rory Bruer, domestic distribution chief for Sony, said: "We got a few bad breaks, the biggest being this historical World Series."

Friday night's game between the Chicago Cubs and the Cleveland Indians drew 19.4 million viewers in the US, a 12-year high, while Saturday night's game was watched by 15.1 million.

North American box office top five

1. Tyler Perry's Boo! A Madea Halloween $16.7m (£13.7m)

2. Inferno $15m (£12.3m)

3. Jack Reacher: Never Go Back $9.6m (£7.9m)

4. The Accountant $8.5m (£7m)

5. Ouija: Origin of Evil $7.1m (£5.8)

Source: ComScore

In the rest of the top five, Tom Cruise's Jack Reacher: Never Go Back dropped a place to number three after taking a further $9.6m (£7.9m), while Ouija: Origin of Evil dropped two places to number five with $7.1m (£5.8m).

Ben Affleck's The Accountant held steady at number four with $8.5m (£7m).

Source:bbc.com