Lucky ticket

Report a typo

Lucky tickets are a kind of mathematical entertainment. A ticket is considered lucky if the sum of the first 3 digits equals the sum of the last 3 digits of the ticket number.

You are supposed to write a program that checks whether the two sums are equal. The code snippet below displays "Lucky" if they are and "Ordinary" if they are not.

However, some parts of the code are missing. Fill in the blanks to make it work!

Input: a string of 6 digits.

Output: either "Lucky" or "Ordinary" (without quotes).

Make sure that you are NOT concatenating strings. To do this, convert each digit in the ticket number to an integer. Don't forget to use proper indices.

Sample Input 1:

090234

Sample Output 1:

Lucky

Sample Input 2:

123456

Sample Output 2:

Ordinary
Write a program in Python 3
# Save the input in this variable
ticket = ...

# Add up the digits for each half
half1 = ...
half2 = ...

# Thanks to you, this code will work
if half1 == half2:
print("Lucky")
else:
print("Ordinary")
___

Create a free account to access the full topic