How to check element position

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Hippy

if country[0] == capitals [0]:
else: print(“Incorrect”)

But if I put for example number 0 than result will be everytime false because string Prague is not equal with string Czech even if answer is correct. Or did I mising something?

Right - this is what I just mentioned in your previous question. Take a look at that comment and post more details if you can.

Also, probably best to keep the entire conversation in a single question rather than spreading it out over multiple posts.

jgodfrey | 2023-02-22 22:37

:bust_in_silhouette: Reply From: Gluon


I think your problem is you are using two arrays. If you have a dictionary you can have it set a country as a key and the capital as the value for example

var dict = {“Czech”: “Prague”, “France”: “Paris”, “Germany”: “Berlin”}

you can then check if the answer the player choose matches what is the value against the dictionary key of the country. Documentation for a dictionary is below;