A new argument introduced in Python 3.8

We saw earlier keywords arguments. Python 3.8 has introduced a new feature in functions known as positional only arguments. For this, / sign is added after the desired arguments, separated by comma. All arguments written before / sign can be passed only positionally and written after this sign can be passed positionally or by using the keyword. The following example illustrates this example.

The error says that we have passed positional only arguments as keyword arguments.

Here, one can observe that variables x and y can be written as positional only, but z can be passed with and without keyword z. Let’s also check what will be the output without using this argument?

We can see that without positional only argument, /, arguments can be passed with or without keywords.

Design a site like this with WordPress.com
Get started