Forum in maintenance, we will back soon 🙂
Notifications
Clear all
Course Homework. Step 11 of 53 in Python Scripting
Python Scripting
3
Posts
2
Users
2
Reactions
677
Views
Topic starter
Here is my script line by line in python:
# An String
my_name="Geoff"
# An Integer
my_age=64
# A Float
my_salary=5.5
# A Boolean
is_hot=True
# DEfine a list
my_fruits= ['Apple', 'Banana', 'Strawberry']
# Printing
print(my_fruits)
#test script
greeting="Hello, World!"
my_integer=3.0
my_float=3.5
my_string="What a beautiful day"
fruits= ['Apple', 'Banana', 'Cherry']
print [fruits]
fruits= ['Apple', 'Banana', 'Cherry', 'Orange']
print [fruits]
my_second_age=64
my_info= ['"Geoff Keall"', 'my_second_age']
print [my_info]
This is my error report:
I'm not sure what not subscript-able means?
geoffreypkeall@Geoffreys-Shared-HP-DJ2130 py_scripts % /usr/local/bin/python3 "/Users/geoffreypkeall/Desktop/py_scripts/dc(datacontainers).py"
['Apple', 'Banana', 'Strawberry']
geoffreypkeall@Geoffreys-Shared-HP-DJ2130 py_scripts % python dc(datacontainers).py
zsh: no matches found: dc(datacontainers).py
geoffreypkeall@Geoffreys-Shared-HP-DJ2130 py_scripts % cd /Users/geoffreypkeall/Desktop/py_scripts
geoffreypkeall@Geoffreys-Shared-HP-DJ2130 py_scripts % python dc(datacontainers).py
zsh: no matches found: dc(datacontainers).py
geoffreypkeall@Geoffreys-Shared-HP-DJ2130 py_scripts % python dc(datacontainers).py
zsh: no matches found: dc(datacontainers).py
geoffreypkeall@Geoffreys-Shared-HP-DJ2130 py_scripts % cd "/Users/geoffreypkeall/Desktop/py_scripts"
geoffreypkeall@Geoffreys-Shared-HP-DJ2130 py_scripts % dc(datacontainers).py
zsh: no matches found: dc(datacontainers).py
geoffreypkeall@Geoffreys-Shared-HP-DJ2130 py_scripts % python dc(datacontainers).py
zsh: no matches found: dc(datacontainers).py
geoffreypkeall@Geoffreys-Shared-HP-DJ2130 py_scripts % /usr/local/bin/python3 "/Users/geoffreypkeall/Desktop/py_scripts/dc(datacontainers).py"
['Apple', 'Banana', 'Strawberry']
Traceback (most recent call last):
File "/Users/geoffreypkeall/Desktop/py_scripts/dc(datacontainers).py", line 18, in <module>
print [my_integer, my_float, my_string]
~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'builtin_function_or_method' object is not subscriptable
geoffreypkeall@Geoffreys-Shared-HP-DJ2130 py_scripts % /usr/local/bin/python3 "/Users/geoffreypkeall/Desktop/py_scripts/dc(datacontainers).py"
['Apple', 'Banana', 'Strawberry']
Traceback (most recent call last):
File "/Users/geoffreypkeall/Desktop/py_scripts/dc(datacontainers).py", line 20, in <module>
print [fruits]
~~~~~^^^^^^^^^
TypeError: 'builtin_function_or_method' object is not subscriptable
['Apple', 'Banana', 'Strawberry']
geoffreypkeall@Geoffreys-Shared-HP-DJ2130 py_scripts % python dc(datacontainers).py
zsh: no matches found: dc(datacontainers).py
geoffreypkeall@Geoffreys-Shared-HP-DJ2130 py_scripts % cd /Users/geoffreypkeall/Desktop/py_scripts
geoffreypkeall@Geoffreys-Shared-HP-DJ2130 py_scripts % python dc(datacontainers).py
zsh: no matches found: dc(datacontainers).py
geoffreypkeall@Geoffreys-Shared-HP-DJ2130 py_scripts % python dc(datacontainers).py
zsh: no matches found: dc(datacontainers).py
geoffreypkeall@Geoffreys-Shared-HP-DJ2130 py_scripts % cd "/Users/geoffreypkeall/Desktop/py_scripts"
geoffreypkeall@Geoffreys-Shared-HP-DJ2130 py_scripts % dc(datacontainers).py
zsh: no matches found: dc(datacontainers).py
geoffreypkeall@Geoffreys-Shared-HP-DJ2130 py_scripts % python dc(datacontainers).py
zsh: no matches found: dc(datacontainers).py
geoffreypkeall@Geoffreys-Shared-HP-DJ2130 py_scripts % /usr/local/bin/python3 "/Users/geoffreypkeall/Desktop/py_scripts/dc(datacontainers).py"
['Apple', 'Banana', 'Strawberry']
Traceback (most recent call last):
File "/Users/geoffreypkeall/Desktop/py_scripts/dc(datacontainers).py", line 18, in <module>
print [my_integer, my_float, my_string]
~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'builtin_function_or_method' object is not subscriptable
geoffreypkeall@Geoffreys-Shared-HP-DJ2130 py_scripts % /usr/local/bin/python3 "/Users/geoffreypkeall/Desktop/py_scripts/dc(datacontainers).py"
['Apple', 'Banana', 'Strawberry']
Traceback (most recent call last):
File "/Users/geoffreypkeall/Desktop/py_scripts/dc(datacontainers).py", line 20, in <module>
print [fruits]
~~~~~^^^^^^^^^
TypeError: 'builtin_function_or_method' object is not subscriptable
Is it important what sort of brackets I use and when a string is part of a variable does it need additional speech marks and does it matter whether the speech marks are double or single?
Any help great-fully received Thank You,
Geoff
Posted : 07/03/2023 5:38 am
Topic starter
Mostly syntax problems. After I fixed the brackets and braces as well as too many speech marks and wrong type it all worked.
Posted : 07/03/2023 7:39 am
SSAdvisor and Hasan Aboul Hasan reacted
Glad to hear that 🙂
Posted : 07/06/2023 9:17 am
Forum Information
Our newest member: Jayant Kumar
Forum Icons:
Forum contains no unread posts
Forum contains unread posts
Topic Icons:
Not Replied
Replied
Active
Hot
Sticky
Unapproved
Solved
Private
Closed