forked from 0xfaust/NSA_COMP3321
-
Notifications
You must be signed in to change notification settings - Fork 0
/
02_21.py
25 lines (20 loc) · 1012 Bytes
/
02_21.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
''' Lecture 02, Exercise 21
Write an 'April fools' color_swapper function that takes my_color and
neighbor_color as inputs and prints a message declaring your and your
neighbour's favourite colours are respectively. Add a line before the print
that swaps the contents of the variables so that now the message is printed
with your favourite colours swapped. Run your function and then print the
contents of my_color and neighbor_color. How were you able to swap them in the
function without swapping them in your notebook?
'''
def color_swapper(my_color, neighbor_color):
my_color, neighbor_color = neighbor_color, my_color
print('Your favourite color is: ' + my_color)
print('Your neighbours favourite colour is: ' + neighbor_color)
my_color = input('Please enter your favourite colour: ')
neighbor_color = input('Please enter your neighbour\'s favourite colour: ')
color_swapper(my_color, neighbor_color)
print(my_color)
print(neighbor_color)