Reputation: 13
#while
#import re
A= float (input("Enter Number :"))
B= float (input("Enter Number :"))
if (any(x.isalpha() for x in A)):
print ("No Letters Please")
C= (A/B)
print (C)
If i declare it as a string Line 6 works but then Line 10 Does not Work
Upvotes: 1
Views: 451
Reputation: 2018
Strings are iterable objects as they are lists of characters, essentially. Numbers are not iterable. Hence, you should do string iteration first and then convert to float for performing calculations with numbers.
Something like:
A = input("Enter Number :")
B = input("Enter Number :")
if (any(x.isalpha() for x in A)):
print("No Letters Please")
C = (float(A) / float(B))
print(C)
Upvotes: 1