Recently Updated
If Logic
Challenge
1
2
3
4
5
6
Use the programming interface to complete this task. You'll be given a list of numbers.
Input: A list of numbers, separated by commas.
Output: Print hi if the number is 0-50 (inclusive), hey if the number is 51-100 (inclusive), and hello if anything else. Each greeting should have a linebreak after it.
Read the input from a file called if-logic.in that's in the current working directory, and then write your output to a file called if-logic.out.
Solution
1
2
3
4
5
6
7
8
9
10
11
12
13
14
numbers=open("if-logic.in","r").readline().rstrip().split(",")
fout=open("if-logic.out","w+")
for n in numbers:
n=int(n)
if n <= 50 and n >=0:
fout.write("hi")
elif n > 50 and n <=100:
fout.write("hey")
else:
fout.write("hello")
fout.write("\n")
fout.close()
Flag
easyctf{is_it_hi_or_hey_or_something_else}