Python Forum
Trouble when entering the number
Thread Rating:
  • 1 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Trouble when entering the number
#11
It will be less confusing if you keep an open terminal and test the script there.
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#12
You are right. With terminal it is different. I repeat the two correct lines that work with the terminal but not with myCharm:
text=input("enter your text ")    
print("you entered: ", text)             
Here is what the interpreter of myCarm says:
Error:
text=input("enter your text: ") File "<string>", line 1, in <module> NameError: name 'cvfret' is not defined
Do you think I must delete all myCharm and then reinstall the same ???
Moderator Kebap: added code and error tags
Reply
#13
I am sure that PyCharm can't be so inconvenient but I don't use it so can't provide a solution for your question. It's too complicated for me  Big Grin
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#14
(Mar-30-2017, 05:28 PM)sylas Wrote: You are right. With terminal it is different.  I repeat the two correct lines that work with the terminal but not with myCharm:            
text=input("enter your text ")      
print("you entered: ", text)
            Here is what the interpreter of myCarm says:              
Error:
text=input("enter your text: ")  File "<string>", line 1, in <module> NameError: name 'cvfret' is not defined
            Do you think I must delete all myCharm and then reinstall the same ???

It seems like you are using a version of python 2.x so please change input() into raw_input().
Reply
#15
You are right Mr Kebab ! Thank you. Maybe python is more complex than C++. It's Ok with the text, but nobody told me if it is normal that the cursor appears inside the output area with text input, but not with the number input.
Reply
#16
It's not more complex than C/C++.
In Python 2 input() is evaluated as valid Python code. For example:

first_name = input(First name: ")
First name: Victor
Error:
Traceback (most recent call last):   File "<stdin>", line 1, in <module>   File "<string>", line 1, in <module> NameError: name 'Victor' is not defined
It's obvious that I didn't define a variable called 'Victor' and I've got an error. From the documentation:

Quote:input([prompt])
Equivalent to eval(raw_input(prompt)).

This function does not catch user errors. If the input is not syntactically valid, a SyntaxError will be raised.
Other exceptions may be raised if there is an error during evaluation.

https://docs.python.org/2/library/functions.html#input
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#17
(Mar-31-2017, 06:00 AM)sylas Wrote: Maybe python is more complex than C++. It's Ok with the text, but nobody told me if it is normal that the cursor appears inside the output area with text input, but not with the number input.

It's not python complexity here. These are issues from pyCharm. There are other python IDEs as well, if you want to look.
Reply
#18
Since myCharm is not correct I tried my old vim with success. The first line must be: #!/usr/bin/python3. Other good news: Code::Blocks has plugins for python.
Reply
#19
A lot of talk about myCharm?? what is it?
I use PyCharm, and have done so for three years without a single incident.
I suspect that you don't have it set up correctly.
I tried using code blocks (which I always used for C) without much success for python.

If indeed you are using myCharm, dump it and load PyCharm
Reply
#20
There is no problem with PyCharm other than that sylas has it setup to point to python 2.x.
Then he write code for Python  3.x.
Set up Interpreter to point to python 3.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Eliminate entering QR - Whatsapp web automated by selenium akanowhere 1 3,093 Jan-21-2024, 01:12 PM
Last Post: owalahtole
  problem in entering address of a file in input akbarza 0 653 Oct-18-2023, 08:16 AM
Last Post: akbarza
  syntaxerror when entering a constructor MaartenRo 2 1,993 Aug-03-2020, 02:09 PM
Last Post: MaartenRo
  How to Stop Sentinel Value from Entering Final Output ZQ12 3 3,244 Nov-11-2019, 07:25 AM
Last Post: perfringo
  Error when entering letter/character instead of number/integer helplessnoobb 2 7,082 Jun-22-2019, 07:15 AM
Last Post: ThomasL
  Program not entering if statement on false. Scottx125 4 2,965 Nov-12-2018, 06:30 PM
Last Post: Scottx125
  Entering an expression with "input" command johnmnz 3 3,496 Sep-01-2017, 05:20 PM
Last Post: metulburr

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020