President Carter yesterday condemned Soviet intervention in Africa as "a danger" to Russian-American relations. But he said the Soviet Union would never achieve permanent influence in Africa, because of its "innate racism toward black people."

Carter issued his sharpest warning so far against Soviet arms sales and the use of Cuban troops in Africa during a 90-minute town meeting here.

Earlier, he was cheered by one of the largest domestic crowds of his presidency - an estimated 40,000 people - at the dedication of a park on the site of the 1974 Spokane World's Fair.

That turnout brought a successful windup to a three-day tour of politically hostile western states.

In his final day's sweep through Oregon and Washington, Carter condemned the medical profession as the "major obstacle" to health care improvements, broadening an attack on the "selfishness" of professions that he began Thursday with a dressing down of lawyers in a Los Angeles speech.

As he flew back to the capital, Carter threatended to veto tuition-tax credit legislation if passed by Congress and said he would not change the terms of his Middle Eastern jet sales package to satisfy critical lawmakers.

The net effect was to show the politically embattled chief executive flexing his muscles at challenges both at home and abroad.

In criticizing Soviet actions in Africa, Carter said the Russians were making a major mistake "trying to buy friendship with destructive weapons." He said "excessive" arms sales to Ethiopia and Somalia had led to the fighting in the Horn of Africa. And he condemned the presence of Cuban troops in Africa as "a danger to nurturing U.S.-Soviet relations."

"The Soviets know how deeply I feel about this," Carter said, adding that Secretary of State Cyrus R. Vance had advised them to "be careful" when he was in Moscow two weeks ago.

The president stopped short of directly linking Soviet actions in Africa to the continuation of strategic arms talks between the two superpowers. But his words were the strongest warning he has given the Russians since taking office.

He also challenged them on a sensitive point by saying their "innate racism toward black people" was recognized by Africans, particulary when contrasted to the attitude of the United States.

He said his own visit to Nigeria convinced him that the religious feeling of Africans gave the United States an advantage over the "atheistic" Soviets in seeking friends.

Carter was in an upbeat mood after participating in the dedication of a park here on a bracing, sunny day, with the cheers of a crowd of thousands in his ears.

There, he returned to the theme of "selfishness" that had sparked his Los Angeles criticism of the nation's lawyers.

Condemning "selfish grasping for advantage" by "privileged people," he sounded the keynote of an emerging political strategy in which he portrays himself as the champion of the abused clientele of highly paid professionals.

"I know that lawyers are concerned about their clients," he said at the town meeting. "But when they organize into a bar association, the responsibility of that group is to protect the interests, not of clients, but of lawyers.

"I know that doctors care very seriously about their patients. But when you let doctors organize into the American Medical Association, their interest is to protect the interests, not of patients, but of doctors. And they have been the major obstacle to progress in our country in having a better health care system in years gone by."

"So I look upon myself as a spokesman for the client and the medical patient . . .," the president declared.

Carter aides - battered by weeks of bad news from the public opinion polls - were jubilant at the initial response to his condemnation of lawyers. Their reaction made it clear that they believed he had found a productive way of regaining the political initiative.

His new combativeness also showed in his declaration that he would do "everything in my power" to block congressional enactment of income tax credits to families with youngsters attending private schools.

The House on Thursday defied the president by making room in its fiscal 1979 budget resolution for the passage of such tuition tax credits. Carter said he would veto such legislation if it reached him, and said the administration's alternative of expanded student loans is "a better way" of helping meet education costs.

For the second day in a row, Carter rejected suggestions that he might compromise with Congress on the terms of the proposed sales of jet fighters to Israel, Egypt and Saudi Arabia. Calling the controversial suggestion that the Saudis be sold 60 F15s "a very modest request," Carter declared that "no other government has been more helpful to me" than Saudi Arabia.