Ask Question

Write a sequence of statements that finds the first comma in the string associated with the variable line, and associates the variable clause the portion of line up to, but not including the comma. You may assume that an int variable pos, as well as the variables line and clause, have already been declared.

+1
Answers (1)
  1. 1 April, 00:35
    0
    As given in the question assuming that the necessary variable are declared, the below line would satisfy the expectation of the question.

    clause = line. split (',') [0]

    Explanation:

    Split is string function which enable us split the text based on the character that is given as a parameter. Split () accepts a single parameter which accepts the splitter character.

    According to the question the given string should be separated by comma and the first sentence before comma should be assigned to the clause variable. So line. split (',') [0] will do that.

    The number '0' inside the square bracket represent the first sentence after splitting with comma.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Write a sequence of statements that finds the first comma in the string associated with the variable line, and associates the variable ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers