What’s wrong with the code? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What’s wrong with the code?

It just won’t let me use the symbols. https://code.sololearn.com/cra9th6ESjC9/?ref=app

7th Oct 2018, 2:06 PM
Daniel
Daniel - avatar
23 Answers
+ 1
It now works. Thanks a lot. Still gotta learn a lot. I still haven’t managed to learn from the try/except blocks
7th Oct 2018, 3:35 PM
Daniel
Daniel - avatar
+ 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
7th Oct 2018, 4:04 PM
Daniel
Daniel - avatar
+ 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
7th Oct 2018, 4:08 PM
Daniel
Daniel - avatar
0
You just need to write any Sm4sh character, no big deal.
7th Oct 2018, 2:07 PM
Daniel
Daniel - avatar
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')
7th Oct 2018, 2:44 PM
Ulisses Cruz
Ulisses Cruz - avatar
0
Alright, thanks a lot!
7th Oct 2018, 2:57 PM
Daniel
Daniel - avatar
0
https://code.sololearn.com/cra9th6ESjC9/?ref=app Still get an error, which I don’t understand. Thanks for the int tip, though
7th Oct 2018, 3:11 PM
Daniel
Daniel - avatar
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')
7th Oct 2018, 3:24 PM
Ulisses Cruz
Ulisses Cruz - avatar
0
I will. Thank you
7th Oct 2018, 3:25 PM
Daniel
Daniel - avatar
0
So I get except ValueError as an invalid syntax
7th Oct 2018, 3:28 PM
Daniel
Daniel - avatar
0
you forgot to put the "try'
7th Oct 2018, 3:30 PM
Ulisses Cruz
Ulisses Cruz - avatar
0
Also, indent the code like I did.
7th Oct 2018, 3:31 PM
Ulisses Cruz
Ulisses Cruz - avatar
0
Oh okay
7th Oct 2018, 3:32 PM
Daniel
Daniel - avatar
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
7th Oct 2018, 3:38 PM
Daniel
Daniel - avatar
0
What exactly are you trying to do?
7th Oct 2018, 3:40 PM
Ulisses Cruz
Ulisses Cruz - avatar
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')
7th Oct 2018, 3:51 PM
Ulisses Cruz
Ulisses Cruz - avatar
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
7th Oct 2018, 3:51 PM
Daniel
Daniel - avatar
0
Oh god, that is a big code. Let me try
7th Oct 2018, 3:52 PM
Daniel
Daniel - avatar
0
It recognizes all names, but the non written in the code
7th Oct 2018, 3:54 PM
Daniel
Daniel - avatar
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
7th Oct 2018, 3:55 PM
Daniel
Daniel - avatar