Here is my code. I thought I was ready after the caesar cipher, but I was wrong. In my point of visualization and what I learned from the previous theories and some debate with gemini and copilot, I created the funtion and variables at the same time as I go, then used paramters of name and stats. Then I focused on pointing to parameters in my conditionals.
I was thinking that parameters are placeholders of the variables, but it’s quite random like quantum. I read my codes plainly, but well…
Your code so far
full_dot = '●'
empty_dot = '○'
# Name Validation
char_name = str
max_name_lenght = 10
# Stats Validation
char_stats_list = [strength, intelligence, charisma]
char_stats = int
min_stat_points = 1
max_stat_points = 4
required_stat_sum = 7
def character_name(name, stats):
if name != char_name:
return 'The character name should be a string'
if name == "":
return 'The character should have a name'
if len(type(name, max_name_length)) > 10:
return 'The character name is too long'
if :
return 'The character name should not contain spaces'
if stats != int:
return 'All stats should be integers'
if stats < 1:
return 'All stats should be no less than 1'
if stats > 4:
return 'All stats should be no more than 4'
if :
return 'The character should start with 7 points'
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:146.0) Gecko/20100101 Firefox/146.0
Plus, the blank ifs. I can’t figure out how to tell the machine that specific actions. I did not want to search the internet or use AI for this, because I wanted to see what my brain has really retained.
Hi, I added a comment on my post. I really have no idea how I will be able to tell the machine to deny character name with spaces and also I can’t also think of a way to tell the machine how to check if the total points won’t exceed 7 points.
I don’t get it. I am not trying to check for data type. How I understand it is, if name is not equal to char_name (which should be string as I did create a variable that says char_name = str), then return ‘The character name should be a string‘. The rest of the conditionals follow the same logic
I’m lost. Isn’t the conditionals for actions like executing the condition ‘cause I don’t get why you are talking about checking. I really did read the theories and I also have typed each of them in writer, so I have some reference. But it’s in the way I understood them.
I’ve played colobot before and I used the same way of thinking or interpreting, you know, coding it.
if you try to check if 8 is an int with 8 == int, it’s False because they are not equal
but the data type of 8 is int, there is the type function that gives the type of something, so if you do type(8) it will output int, you can use this to check the type of your arguments
but you also need to fix the function definition first
the function will be called with 4 arguments, which means it will cause an error, and nothing will work. You must write 4 function parameters
Oh, then how do I know that if I put another parameter it will directly refer to one of the variables? Isn’t that how it works? This is a classic for me, I tried to learn japanese but could not converse in japanese Now, I am having the same problem with python.
a parameter refers to the value passed in to the function
if you define a function with def character_name(name, stats):, and you call it with create_character('ren', 4, 2, 1), then name is 'ren', stats is 4, but the 2 and 1 do not have a parameter to go into, and the program errors out and crashes because of it. You must write 4 parameters when you create the function
I think I am starting to notice something, I’m not quite sure. Still my mind is confused with dynamic typing. Why can’t it be like hey I’m pointing to this so just please do this Anyhow, it sounds like my understanding of Python is not really quite there yet. I’ll review everything again, I really want to learn how to code. It’s just so tedious. I’ll try again after some time.
I figured out I’m flying blind. I thought I was conversing with the machine using the python language. It turns out there are prerequisites, like the in operator. It’s been 7 hours of non-stop reading, unfortunately and according to what I researched about programming, if I do not understand the protocols of the object on what is allowed or not allowed to do, then I simply sound gibberish to the machine.
My goal is to learn the language so I can communicate with it but somehow even when knowing the operators or their definitions I still can’t make it comprehensible to me nor to the machine.
Should I stop learning programming? I need real-world expert advice if it’s not for me.
If you find it tedious and don’t want to learn programming, then don’t. Everyone has to start at the beginning though.
Don’t do this. It’s likely why you haven’t learned well and did not write this program correctly. Everyone has to start at the beginning though. Don’t try to skip ahead.
If you want to get stronger then lift weights, don’t ask gemini and copilot for advice.
Lifting weights or jogging might seem tedious. Until you become good at it, then it’s addictive. Programming is the same.
Read the instructions and implement them one at a time.
You should have a function named create_character.
def character_name(name, stats):
The function should accept, in order, a character name followed by three stats: strength, intelligence, and charisma.
Your function accepts name and stats but the instructions say it should accept name, strength, intelligence, and charisma
If you want to continue, go ahead and implement User Story 2. I would reset the lab though as you have a lot of code that doesn’t work or doesn’t make sense.
Just go one step at a time, and make sure each is implemented correctly.
finally got the check marks for the character_name instructions…
Thanks for the hints, I was in so deep that I could not see and made things gibberish for the machine. My previous work looks complex and somewhat cool to do non-programmer. Simplicity is key.
By the way, I successfully prompted AI without giving me examples or explaining stuffs to me like it’s patronizing me, then simply tell me that the line is not correct and remind me to analyze the line of code. It feels like an imaginary drill instructor is shouting to me, but hey 90’s were the time where we still got punishments like those. My brain still works by those standards - like a toddler.
Will post when I hit another brutal wall! But it will be more clearer and specific. I sound too much, but it worked!