---
id: 6958ea03cb1c4684c138754a
title: Step 21
challengeType: 20
dashedName: step-21
---

# --description--

In this final step, you will calculate the final price of the movie ticket using the values calculated in the previous steps.

The final ticket price is calculated by adding the extra charges and service charges to the base price, and then subtracting the discount.

Inside the body of the last `if` statement, below the `print('Service charges:', service_charges)` line, calculate the final price of the ticket and store it in a variable named `final_price`.

Finally, print a message that shows `Final price of ticket:` followed by the value of `final_price`.

# --hints--

You should declare a variable named `final_price`.

```js
({ test: () => (runPython(`assert _Node(_code).find_ifs()[4].find_bodies()[0].has_variable("final_price")`)) })
```

You should assign the value `base_price + extra_charges + service_charges - discount` to `final_price`.

```js
({ test: () => (runPython(`
import itertools  
perms = itertools.permutations(['+ base_price', '+ extra_charges', '+ service_charges', '- discount'])  
values = (' '.join(perm).lstrip('+') for perm in perms)  
solutions = (f'final_price = {v}' for v in values)  
var = _Node(_code).find_ifs()[4].find_bodies()[0].find_variable("final_price")  
assert any(var.is_equivalent(s) for s in solutions)
`)) })
```

You should have `print('Final price of ticket:', final_price)` below your `final_price` variable.

```js
({ test: () => (runPython(`
print_call = "print('Final price of ticket:', final_price)"  
_body = _Node(_code).find_ifs()[4].find_bodies()[0]
assert _body.has_call(print_call)
`)) })
```

# --seed--

## --seed-contents--

```py
base_price = 15
age = 21
seat_type = 'Gold'
show_time = 'Evening'

if age > 17:
    print('User is eligible to book a ticket')

if age >= 21:
    print('User is eligible for Evening shows')
else:
    print('User is not eligible for Evening shows')

is_member = False
is_weekend = False

discount = 0
if is_member and age >= 21:
    discount = 3
    print('User qualifies for membership discount')
else:
    print('User does not qualify for membership discount')
print('Discount:', discount)

extra_charges = 0
if is_weekend or show_time == 'Evening':
    extra_charges = 2
    print('Extra charges will be applied')
else:
    print('No extra charges will be applied')
print('Extra charges:', extra_charges)

if age >= 21 or age >= 18 and (show_time != 'Evening' or is_member):
    print('Ticket booking condition satisfied')

    service_charges = 0
    if seat_type == 'Premium':
        service_charges = 5
    elif seat_type == 'Gold':
        service_charges = 3
    else:
        service_charges = 1
    print('Service charges:', service_charges)

--fcc-editable-region--
    
--fcc-editable-region--
else:
    print('Ticket booking failed due to restrictions')
```

# --solutions--

```py
base_price = 15
age = 21
seat_type = 'Gold'
show_time = 'Evening'

if age > 17:
    print('User is eligible to book a ticket')

if age >= 21:
    print('User is eligible for Evening shows')
else:
    print('User is not eligible for Evening shows')

is_member = False
is_weekend = False

discount = 0
if is_member and age >= 21:
    discount = 3
    print('User qualifies for membership discount')
else:
    print('User does not qualify for membership discount')
print('Discount:', discount)

extra_charges = 0
if is_weekend or show_time == 'Evening':
    extra_charges = 2
    print('Extra charges will be applied')
else:
    print('No extra charges will be applied')
print('Extra charges:', extra_charges)

if age >= 21 or age >= 18 and (show_time != 'Evening' or is_member):
    print('Ticket booking condition satisfied')

    service_charges = 0
    if seat_type == 'Premium':
        service_charges = 5
    elif seat_type == 'Gold':
        service_charges = 3
    else:
        service_charges = 1
    print('Service charges:', service_charges)

    final_price = base_price + extra_charges + service_charges - discount
    print('Final price of ticket:', final_price)
else:
    print('Ticket booking failed due to restrictions')
```
