I want to augument variable "age" on 1, but it brings me this error
I tried change print(f"Happy birthday {namename} your age is turned from{age} to {age_second}") to print(f"Happy birthday {namename} your age is turned from{age} to {age} + 1") or something that. But it hasn’t work. It following syntax of code there is introduced the second variant I tried.
namename = input("What is your name")
print(f"Hello {namename}")
age = input("How old are you?")
age_second = int({age} + 1)
print(f"Happy birthday {namename} your age is turned from{age} to {age_second}")
>Solution :
Outside of an F-string (f"..."), the syntax {age} means something else: it creates a set with one item (namely the value of age).
Which is why you get the error: you’re trying to add an int (1) to a set ({age}), which is an operation that Python doesn’t support.
Instead, you want to take the integer value of the input, and add one to it:
age = input("How old are you?")
age_second = int(age) + 1