To calculate the number of unique handshakes in a room, given the number of people. Where n is the number of people.
I am trying to calculate the number of handshakes people in a given room would exchange given the number of people, in python. This is written in Python 3.
people = input("How many people were there?")
no_handshakes = ((people - 1) *people)/2
print("No. of people: ", people)
print("No. of handshakes: ", no_handshakes)
When I run this code in the python shell, it generates this error.
Traceback (most recent call last):
File "C:\Users\Tanaka\Desktop\Cloud\python101\peoplehandshakescalculator.py", line 2, in <module>
no_handshakes = ((people - 1) *people)/2
TypeError: unsupported operand type(s) for -: 'str' and 'int'