Learnerslesson
   JAVA   
  SPRING  
  SPRINGBOOT  
 HIBERNATE 
  HADOOP  
   HIVE   
   ALGORITHMS   
   PYTHON   
   GO   
   KOTLIN   
   C#   
   RUBY   
   C++   




fromkeys( ) FUNCTION


The fromkeys( ) Function returns a Dictionary with the given keys and the specified value.


Example :


x = (5, "John", "Python")
y = ("Is a Value")
z = dict.fromkeys(x, y)
print(z)


Output :



  {5: 'Is a Value', 'John': 'Is a Value', 'Python': 'Is a Value'}

So, in the above code we have created a 'Tuple' using braces '( )'.


x = (5, "John", "Python")

And a 'Tuple' 'y',


y = ("Is a Value")

Then used 'dict.fromkeys( )' Function to form the Dictionary with below values


And initialised to the variable 'x'.


java_Collections

Just remember, the 'Value', 'Is a Value' is common for all the 'Keys'.