Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Help with finding correct topic in Python learning

I am starting at zero with Python. I need to know which topics in Python do I need to study to understand below two statements. The confusing part is more than one variable on the left side of assignment.

(x_train, y_train), (x_test, y_test) = mnist.load_data()
x_train, y_train = load_image_dataset(...)

that's called unpacking (or iterable unpacking)

long story short - on the right side there is some data structure and values are assign to variables on the left side
in your first example mnist.load_data() shuld return tuple/list of 2 tuples/list with 2 elements each, e.g. ((1, 3), (5, 2)) (just arbitrary numbers for example) and then x_train = 1, y_train=3, x_test=5, y_test=2

check this SO question and accepted answer

there is also extended unpacking

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Finding nearest point of a Multidigraph in Python 3.7 stixmagiggins 5 185 Aug-24-2019, 08:51 AM
Last Post: ThomasL
  Not quite getting the correct Output from a function twinpiques 3 165 Aug-04-2019, 11:53 PM
Last Post: twinpiques
  read text file and write into html with correct link jacklee26 4 162 Aug-02-2019, 05:48 AM
Last Post: jacklee26
  How do I create a actor if I subscribe to a specific topic? sdf1444 0 89 Aug-01-2019, 09:29 PM
Last Post: sdf1444
  Can you help about my learning project Qusha 1 122 Jul-21-2019, 07:46 PM
Last Post: Yoriz
  Learning Python in a month MuhammadNauman 1 144 Jul-17-2019, 11:53 AM
Last Post: metulburr
  How to simplify square finding program? meknowsnothing 3 318 Jun-11-2019, 08:20 PM
Last Post: meknowsnothing
  learning to while loop iofhua 7 259 May-24-2019, 09:46 AM
Last Post: DarkCraftPlayz
  Return in correct json format UtiliseIT 3 349 May-13-2019, 11:24 AM
Last Post: snippsat
  How to continue in loop until correct input received sunnyarora 10 487 May-04-2019, 02:37 PM
Last Post: Yoriz

Forum Jump:

Users browsing this thread: 1 Guest(s)