All,
I have the following code:
val1 = str(input("Enter string element 1/3: "))
val2 = int(input("Enter integer element 2/3: "))
val3 = float(input("Enter float element 3/3: "))
lst = [val1, val2, val3]
tpl = (val1, val2, val3)
dict = {"First element: ":val1, "Second element: ":val2, "Third element: ":val3}
print("/n")
print("Here is your list: ", lst)
print("Here is your tuple: ", tpl)
print("Here is your dictionary ", dict)
print("/n")
val4 = input("Add a new str list element: ")
lst.append(val4)
print("Here is your new list ", lst)
But i seem to get this return:
Traceback (most recent call last):
File "C:/Python27/Test2", line 1, in <module>
val1 = str(input("Enter string element 1/3: "))
File "<string>", line 1, in <module>
NameError: name 'test' is not defined
However, int and float both work - so why doesn't string? It's saying that 'test' isn't defined, but i thought it because defined after the user inputted the word?
Any help would be greatly appreciated.
Regards,