samedi 13 janvier 2018

How python if statement takes arguments?

Here the if_statement is taking only 'input_given' as an expression but the 'input_given' does not represent any statements(True or False).Then how does the if_statement recognize whether its an empty string or not?

This code accepts a sequence of lines as input and prints the lines after making all characters in the sentence capitalized. Suppose the following input is supplied to the program:

Hello world
Practice makes perfect

Then, the output will be:

HELLO WORLD
PRACTICE MAKES PERFECT

The code

lines = []
while True:
 input_given = input()  

 if input_given:
    lines.append(input_given.upper())
 else:
    break;

for sentence in lines:
 print (sentence)

Thank you

Aucun commentaire:

Enregistrer un commentaire