0

I am very new here and Python programming as well. I am using Pycharm. I read in a book that input function returns string value by default. But in my case, it returns integer by default. What is the problem? Please help me. I have written exactly this in pycharm. And it returns integer value directly.

number=input("Enter a number:")                                                     
print(number)                                                                                         
print(type(number))

output shows the number correctly that I input. But the type shows <type 'int'>. Please help me.

azro
  • 53,056
  • 7
  • 34
  • 70
Noor Mia
  • 1
  • 1
  • 5
    Run your code on Python 3, not the dead Python 2. – deceze Dec 11 '21 at 08:53
  • https://stackoverflow.com/questions/20449427/how-can-i-read-inputs-as-numbers – azro Dec 11 '21 at 08:55
  • Python version-3.10.1 and Pycharm version 2021.3 – Noor Mia Dec 11 '21 at 08:57
  • Where do these numbers come from and how exactly are you executing the code? – deceze Dec 11 '21 at 09:03
  • @Noor Thats is ONE python running on your system - but not the one that executes this code - that is a python 2 : [how-do-i-detect-the-python-version-at-runtime](https://stackoverflow.com/questions/9079036/how-do-i-detect-the-python-version-at-runtime) – Patrick Artner Dec 11 '21 at 09:18
  • Oh Thanks all! My problem is solved. Though I have installed Python 3.10.1 but in Pycharm python 2 was doing it's job. After changing it to Python 3, Problem is solved! Thanks all for your help!! – Noor Mia Dec 11 '21 at 09:34

0 Answers0