Kevin O'Leary's No. 1 money mistake to avoid during periods of high inflation

From gas prices to grocery stores, inflation is hitting Americans where it hurts: their wallets. 

In March, the price of consumer goods was up 1.2% since February and 8.5% year over year, according to the Labor Department's most recent data. It seems like anywhere you look, your dollar isn't going as far as it used to. 

For Kevin O'Leary, O'Shares ETFs chairman and judge on CNBC's "Money Court," the most important thing Americans can do with their money during period of high inflation is to avoid keeping the bulk of it in a low-interest savings account. 

"Right now in a bank account, you're getting [very little] interest," O'Leary says. "And inflation is over 6%. So you're actually losing money every 12 months." 

In other words, if your bank account is giving you 0.01% interest each month, but inflation is at 6%, the value of your money actually decreases by 5.99% over that time frame. 

O'Leary said that when he was young, he "learned the hard way" that banks were a bad place to keep his cash when he saw how little interest his savings account was earning. 

"I realized 'Wow, I'm not making anything on this cash sitting around,' and that I had to learn how to invest," he says. "And that's exactly what I did."

O'Leary sides with the experts, including Warren Buffett, who recommend that people put their money into index funds, which are automatically diversified. Despite market volatility, O'Leary points out that the S&P 500 has traditionally outpaced inflation. 

O'Leary isn't against savings accounts in general. He recommends that everyone "have three months of salary on hand in case of emergency," but says going above that results in needlessly losing money to inflation. 

"Savings in cash in a bank account make basically no interest, certainly after inflation," he says. "Investing is keeping pace with the equity and stock markets. And I think you've really got to understand the difference between the two."