The raw_input function always returns the type 'string' raw_input docs , so in this case, we must convert the string totPrimes enter the type 'int' or 'float' as follows:
totPrimes = raw_input("Please enter the primes: ") totPrimes = float(totPrimes)
You can combine them as follows:
totPrimes = float(raw_input("Please enter the primes: "))
To compare things in python count < totPrimes , a comparison should make sense (numbers for numbers, strings for strings) or the program will work, and the while count < totPrimes : while loop will not while count < totPrimes : .
You can use try / except to protect your program. exception management
For people taking the Programming for All course, you can take a few hours and evaluate this path. an if / else statement you should try to figure out.
source share