There are a total of 50 students and only 6 of them do not take either class. That leaves 50- 6= 44 students who take one or both of those classes.
We are told that there are 38 students in the cooking class and 34 in the painting class. My goodness, 38+ 34= 72 which is larger than 44! How do you suppose that could happen?