Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Revisions

3 of 7
deleted 59 characters in body

Python 3, 136 bytes

def f(s,g={}):
	for k in filter(lambda a:'='in a,s):
		*v,l=k.split('=')
		for r in v:
			try:g[r]=eval(l)
			except:g[r]=g[l]
	return g

Try it online!

Python really isn't my strong suit for golfing :/ Note the use of tabs rather than spaces, so the indentation levels are still a single byte each. Takes input as a list of lines with assignments separated by = (no spaces) and returns a dictionary of variables and values

AltStyle によって変換されたページ (->オリジナル) /