DeAndre Arnold, a senior at Barbers Hill High School in Mont Belvieu, appeared in an episode of "The Ellen Show" that aired Wednesday.
At the start of the segment, DeGeneres told Arnold, "I'm sure this is not easy or comfortable for you," referring to his appearance on television. "But I want you to just relax and know that I'm here for you."
"You get good grades," DeGeneres said. "You've never been in trouble, ever. This is the first time anything has come up. And now, you haven't been in school for weeks because of this situation."
The Morning Rundown
Get a head start on the morning's top stories.
Arnold has worn dreadlocks for years and has said he always followed the dress code because he kept his hair off his shoulders, above his earlobes and out of his eyes, by tying up his dreadlocks. He told DeGeneres he was informed he was in violation of the dress code after the Christmas break.
"Every day I would go to school, I would be in dress code," he told DeGeneres. "But the thing with them is, if it was let down, I would be out of dress code."
DeGeneres asked if there were girls in his school with long hair, to which he responded in the affirmative and said: "There's plenty of girls with long hair at my school. Like, if girls can have long hair, why can't I have long hair?"
DeGeneres said that was the point she was trying to make.
"I just personally think you should be able to wear your hair however you want, especially if there's girls with long hair," she said. "What's the difference if girls have long hair and if guys have long hair?"
She said she did not think the policy was fair and asked Arnold to explain why his dreadlocks are important to him.
"It's really important to me because my dad is from Trinidad," he told her, adding that his dreadlocks are part of his culture and heritage. "And I really wish the school would kind of be open to other cultures and just, at least let us try to tell you some things. Don't just shut us out."
DeGeneres agreed. "I think that's what school's supposed to do," she said, "is teach you about other cultures. You're not supposed to teach them. They're supposed to teach you."
African Americans make up 3.1 percent of the Barbers Hill Independent School District population.
Barbers Hill High School has not responded to multiple requests for comment.
Jami Navarre, spokeswoman for Barbers Hill Independent School District, declined an interview request and said the district would not be commenting further on the matter. She pointed NBC News to a statement the district released last week saying that the high school allows dreadlocks, but has for decades had a "a community-supported policy" about the length of male students’ hair.
Arnold, who has been out of school for weeks, said if he doesn't cut his hair, his only options are in-school suspension or an alternative school for children with behavioral issues.
DeGeneres then spoke into the camera and urged officials "to do the right thing."
"I am begging you. This kid is a good kid. He deserves to graduate, to walk with all the other kids," she said. "He's a good guy. I just am urging you to do the right thing. Please."
Afterward, she invited singer Alicia Keys on stage to award Arnold, who plans to become a veterinarian, a $20,000 scholarship for college.
"I want to tell you that, I couldn't believe the story when I heard it," Keys told Arnold. "And I'm super proud of you for standing up for what you know is right. And I know that the school needs to do the right thing."
Janelle Griffith is a breaking news reporter for NBC News.