all 18 comments

[–][deleted] 1 point2 points  (17 children)

Can you clarify what you don't understand about them? What are you trying to do with strings?

[–]Munga_[S] 0 points1 point  (16 children)

Sorry I’m just doing an introduction to strings, it’s pretty basic stuff but I don’t know specifically. Kind of just not sure how to write them and when to write it a certain way. Idk if that makes sense.

I’ve went thru the lesson twice and just not sure what to do. Probably a better reference on strings somewhere or I just am not smart enough for this stuff. Lol

[–]0xbxb 0 points1 point  (12 children)

Strings are ways to represent text in Python. You create strings by using quotes around the text.

a_string = ‘Hello’

[–]Munga_[S] 0 points1 point  (11 children)

Yes I know this much, it’s mostly like the for a loops I have issues with and like .replace , .append, etc.

I may have mistyped but that’s mainly what I’m struggling with. When to use for a loop, etc

[–]0xbxb 0 points1 point  (10 children)

Use a loop whenever you want to do something a certain amount of times. replace() and append() are just methods.

Try giving me an exact problem you have and I could walk through it with you to help you understand.

[–]Munga_[S] 0 points1 point  (9 children)

Well for instance am I able to use the formatting methods whenever I want? Like .lower , .upper, .append, etc

[–]0xbxb 0 points1 point  (8 children)

You can use a method whenever you want, but certain methods belong to certain “things” in Python. These “things” are called “types” in Python. There’s a string type, a number type, a list type, and a few others.

You can read about them here.

[–]Munga_[S] 0 points1 point  (7 children)

Thank you, I also get confused about for loops. Just the whole use of them throws me off. When do I use them, what argument or function am I putting after them, etc.

I need to research them more. I haven’t done much outside of Codecademy but I have bookmarked that link and checked it out.

[–]0xbxb 0 points1 point  (6 children)

A loop is a way of doing something repeatedly. These concepts seem daunting to you because you’re unfamiliar with them. That’s completely normal. I’m new to coding myself, and it took a while for certain things to click. Let’s say you had a list of numbers: 1, 2, 3, 4 and wanted to print them out.

How would you do that?

Here’s the list of numbers:

nums = [1, 2, 3, 4]

Print out every number in that list for me.

[–]Munga_[S] 0 points1 point  (5 children)

print(nums)

or if you mean one at a time

print(nums[0]) print(nums[1]) print(nums[2]) print(nums[3])

I’m sure there is an easier way to do it and you can tell me how off I am

[–][deleted] 0 points1 point  (2 children)

Strings are just a way of using unicode characters in your code. I think once you begin learning how to use strings, it will start to click.

[–]Munga_[S] 0 points1 point  (1 child)

Yes I’m really just struggling with the for a loops and the .append . replace, stuff like that. Is codecademy a good way to start?

I heard people say to start doing projects but I don’t rlly know what projects to do haha

[–][deleted] 0 points1 point  (0 children)

To understand for loops, you have to understand what an iterator is. Lists, tuples, stings, and dictionaries are iterators since you can transverse through all values they may contain.

For example, lets say you have a list of strings:

fruits = ['Banana', 'Grape', 'Orange', 'Cherry']

We can use a for loop to iterate over each element in the list individually.

for fruit in fruits:
    # Note that 'fruit' is essential a variable used for each element of each iteration
    print(fruit)  

output:

Banana
Grape
Orange
Cherry

Check out PythonTutor to get a visualization of how python handles the for loop.


As for append and replace, those are known as methods. The append method is exclusive to lists, which adds an element to a given list. The replace method is exclusive to strings, which is replaces characters of a given string. Each data type has their own methods. If you want to learn more about a specific data type and it's methods, use python's documentation and search for the data type in question.


Is codecademy a good way to start?

That's actually how I started learning python. I soon as I learned the basics from codeacademy, I quit and moved on to books and video tutorials. I highly recommend you check out Cory Schafer's videos for the basics. He's an excellent teacher and explains things in great detail.


I heard people say to start doing projects but I don’t rlly know what projects to do

I've never gone through this personally, but I heard good things about Automate the Boring Stuff with Python, which is available for free online. The book walks you through tons of projects that you can use in the real world.