I am a new learner of python and tried to take 3 or more variables to store different user-inputs using for loop but when I run it, it says the varibles are not defined.
for i in [p, q, r]:
i = int(input("Enter any value="))
print("Your 1st value=", p)
print("Your 2st value=", q)
print("Your 3st value=", r)
r = dict()
for i in range(3):
r[i] = int(input("Enter any value="))
for i in range(3):
print(f"Your {i} value = {r[i]}")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.