What is the reason why the list does not appear?

Asked 2 years ago, Updated 2 years ago, 36 views

fruit=["apple", "orange", "pear" ]
fruit

I'm self-taught and studying from scratch, but when I execute the above code as shown in the book, nothing appears in the dialog shell.
I'm sorry about this basic thing, but please tell me what I should fix.
My language will be Ver3.6.5 in Python.
Thank you for your cooperation.

Thank you for your comment.

I do it on Windows. Open Python 3.6.5 shell (IDLE) and enter the above code in the text editor in file n new file and click RUN.The shell is empty after >>>.

Will this be conveyed?I'm sorry that there are so many things I don't understand.Thank you.

python python3

2022-09-30 15:37

1 Answers

If you run the program file from Python IDLE, the interpreter does not display the value by simply evaluating the variable.

More specifically,

fruit=["apple", "orange", "pear" ]
fruit

The second line of only evaluates the variable fruit, and Python does not mean output the contents of fruit; however, if you type programs one line at a time on the interpreter, the interpreter will output the resulting value.The following is the result of running it on the interpreter in my environment.In your environment, typing one line at a time into the interpreter instead of running the file should be the same result.

>>fruit=["apple", "orange", "pear" ]
>>fruit
["Apple", "orange", "pear"]
>> 

Use the print function to print as a program.If you edit the program file as follows and run the file with Python IDLE, the contents of the fruit should be displayed properly.

fruit=["apple", "orange", "pear" ]
print(fruit)


2022-09-30 15:37

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.