python - [] became None after appending -


I am trying to store raw input in an empty list I am quite new to the python. And apparently, the input was not in the empty list. Then what happened? Latitude = [] longitude = [] Print Latitude # ** returns [] ** Lat_input = raw_input ("Your latitude is: ") Latitude = Lat .append (Lat_input) Print Latitude # ** No one found me here ** long _input = raw_input (" what is your longitude: ") longitude = longitude.Open (long_input)

I saw some other postings, yet I did not know what I did. what did I miss? Why have my list gone? Thanks, guys!

attachment is an in-place operation; It does not return any value.

Just run:

  underlined. Append (long_input)   

... not

  longitude = longitude .append (long_input)   

This design and intent is: Returning none instead of a value makes it clear that the function is being called for its side effects rather than its return value.

If you did not want to change existing longitude in place, but wanted to create a new list instead of enclosing new items, you can use it instead :

  longitude = long [+]>

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -