Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (11.4k points)

name = input('Enter name here:')
pyc = input('enter pyc :')
tpy = input('enter tpy:')
percent = (pyc / tpy) * 100;
print (percent)
input('press enter to quit')


whenever i run this program i get this

TypeError: unsupported operand type(s) for /: 'str' and 'str'


what can iido to divide pyc by tpy?

1 Answer

0 votes
by (32.3k points)

You can divide pyc by tpy by turning them into integers instead:

percent = (int(pyc) / int(tpy)) * 100;

For python3 the input() function always returns a string.

Browse Categories

...