I want to name a variable in python using the name of an existing variable. For example:
s = "Hello World" words = s.split() numofwords = len(words) word(numofwords) = words[numofwords-1]
I'm not sure what syntax I would use to define the variable in line 4. What my code would hopefully do is print the last word in the string, stored as the variable wordx, x being the number of the last word. (In this case it would be 2.)I'm new to Python so there are probably some mistakes in the code.