When you read 'word' is always a string in python 3+.
so type(word)
is always string. hence you would get the length. Check the output below for your program. i used hard breakpoint using import pdb; pdb.set_trace()
instead of trying to check type(word). I think you should convert string to int / float.
I think converting to float is a best option .
This issue is in python 3. as all data from input is string. you can check here.
$ python t.py
This is an app calculate the lenght of a word
enter the word1
> /Users/sesh/tmp/t.py(6)String_Lenght()
-> if type(word) == int:
(Pdb) word
'1'
(Pdb) type (word)
<class 'str'>
(Pdb) int(word)
1
(Pdb) float(word)
1.0
(Pdb) int('asdfads)
*** SyntaxError: EOL while scanning string literal
(Pdb)
Traceback (most recent call last):
File "t.py", line 13, in <module>
print(String_Lenght(word))
File "t.py", line 6, in String_Lenght
if type(word) == int:
File "t.py", line 6, in String_Lenght
if type(word) == int:
File "/usr/local/Cellar/python/3.6.5_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/bdb.py", line 51, in trace_dispatch
return self.dispatch_line(frame)
File "/usr/local/Cellar/python/3.6.5_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/bdb.py", line 70, in dispatch_line
if self.quitting: raise BdbQuit
bdb.BdbQuit
(qsic-api-django)
sesh at Seshs-MacBook-Pro in ~/tmp