0
What’s wrong with the code?
It just won’t let me use the symbols. https://code.sololearn.com/cra9th6ESjC9/?ref=app
23 Antworten
+ 1
It now works. Thanks a lot. Still gotta learn a lot. I still haven’t managed to learn from the try/except blocks
+ 1
Yes, that worked out. Thank you so much for the help. I will continue learning in the app to try not comit those mistakes. Appreciate the support
+ 1
So now the values can be either erased or used for if == statements to create secondary texts. I’ll try my best at it
0
You just need to write any Sm4sh character, no big deal.
0
Hallomon if you want to compare the value of variable 'character' with 6,
you need to convert character to int:
character = int(input())
if character < 6:
print('u suck')
else:
print('good')
0
Alright, thanks a lot!
0
https://code.sololearn.com/cra9th6ESjC9/?ref=app
Still get an error, which I don’t understand. Thanks for the int tip, though
0
Hallomon if the user do not insert a value when prompt
you will get a ValueError. To solve that put the convertion
inside a try/except block, like this:
try:
character = int(input())
except ValueError:
character = 5
if character < 6:
print('u suck')
else:
print('u good')
0
I will. Thank you
0
So I get except ValueError as an invalid syntax
0
you forgot to put the "try'
0
Also, indent the code like I did.
0
Oh okay
0
The only issue now is that as the character has a fixed value of 5, whatever name I write I’ll get the ‘u suck’ message
0
What exactly are you trying to do?
0
Maybe this is what you want?
But all the names will give 'u suck' because the numbers are less than 6;
to see 'u good' you need to put one or more numbers greater than 6:
#Use capital letters
names = {
'Bayonetta': 1,
'Cloud': 2,
'Rosalina': 3,
'Sonic': 4,
'Ness': 5,
}
character = input()
if names[character] < 6:
print('u suck')
else:
print('u good')
0
Out of 57 characters, you can see that 5 are supposed to mean you are a bad player. Does nkr matter if you do not know the rest as the importance is on the ones you can read in the code. However, if any other character’s name is written, its suposed to say ‘u good’, and ‘u suck’ if any from the above is in the input. Because of that, the else statement
0
Oh god, that is a big code. Let me try
0
It recognizes all names, but the non written in the code
0
the easy solution would be to write all 57 names, but I tried getting the else statement to avoid that, and have less text