[PYTHON] Explain the associative array

Then first write in C #.

ex.cs


using System;
using System.Collections.Generic;
public class Ex{
    public static void Main(){
        var jcpmusicdotcom = new Dictionary<string,string>();
        jcpmusicdotcom["Touhou Lost Word"] = "Lost word chronical";
        jcpmusicdotcom["I'm Salamence"] = "Replica no koi";
        jcpmusicdotcom["Heartwarming shrine"] = "SHAMAN QUEEN";
        foreach(var music in jcpmusicdotcom){
            Console.WriteLine($"{music.Value}Is{music.Key}It is music associated with.");
        }
    }
}

Next, let's write it in Python.

ex.py


class Ex:
    def main():
        jcpmusicdotcom = {}
        jcpmusicdotcom["Touhou Lost Word"] = "Lost word chronical"
        jcpmusicdotcom["I'm Salamence"] = "Replica no koi"
        jcpmusicdotcom["Heartwarming shrine"] = "SHAMAN QUEEN"
        for musickey in jcpmusicdotcom:
            print(f"{jcpmusicdotcom[musickey]}Is{musickey}It is music associated with.")

if __name__ == "__main__":
    Ex.main()

After all, both are influenced by C language, so the writing style does not change much. I like C # and Python, which are "styles that can't be written dirty", but what about you guys? Thank you for your comment.

Recommended Posts

Explain the associative array
Explain the code of Tensorflow_in_ROS
[Python] Combine all the elements in the array