- Aug 5, 2016
- 187
- 1,207
I was working on coding in Ren'Py with a friend (we both are rookies at this). I have attached the piece of code in question below. If I enter any of the values listed in that dictionary, the argument "$ curr = [x for x, y in currencies.items() if curr in y]" returns the correct key. However, if call [curr] it gives me [u'selected key'], for example - I type in dollar at the input screen, instead of returning American currency, it returns [u'American currency'] when I call using [curr]. (Screenshot attached with the error marked.)
How do I get rid of the [u''] and just display American currency?
How do I get rid of the [u''] and just display American currency?
Code:
default currencies = {
"American currency" : ["dollar", "dollars", "cent", "cents", "usd"],
"British currency" : ["pound", "pounds", "shilling", "shillings"],
}
label currency:
$ curr = renpy.input("Which currency do you use?")
$ curr = curr.strip().lower()
$ currtemp = curr # a temporary variable for currency that is not listed in the dict above. User entered currency will be used.
if curr == "":
$ curr = "Other Currency" # if user does not enter any currency name
else:
$ curr = [x for x, y in currencies.items() if curr in y]
if not curr:
$ curr = currtemp
jump currency_conf
label currency_conf:
menu:
"Your currency is [curr]. Is that right?"
"Yes":
"You clicked YES!"
jump endgame
"No":
jump currency