Print method invalid syntax reversing a string [closed]

2024/7/7 22:32:56

Trying to reverse a string in python and can't figure out what is wrong with my program that this is seen as invalid syntax.

print(r)^
SyntaxError: invalid syntax```

Thanks so much here is my code.


s = "Hello! my name is MangoKitty"
r = ''.join(reversed(s.split(''))
print(r)
Answer
  1. You are missing ) at the end of second line.

  2. You are using empty separator s.split('')

https://en.xdnf.cn/q/120201.html

Related Q&A

How QRegularExpression can be passed to Qt::MatchRegularExpression

I am trying this sample code that I found which is really really good. I am also trying to figure out the same thing to find an item and scroll to it, but this time I wanted to match the the string whi…

Python list rearrange the elements in a required order

My main list has 44 names as elements. I want to rearrange them in a specific order. I am giving here an example. Note that elements in my actual list are some technical names. No way related to what I…

GMB API accounts.locations.reviews.list

Can i get source code to get reviews using gmb python code also heard mybusiness is discontinued. I tried using my business api is discontinued can i get the implementation process to look for extract…

How to get words from an online text archive such as pastebin?

Im trying to get the words(users) from a text file hosted online, such as from www.site.com/mytextfile.txt or pastebin.com/raw/1111111. I will have multiple "users", one in each line. My code…

Python Histogram using matplotlib on top words

I am reading a file and calculating the frequency of the top 100 words. I am able to find that and create the following list:[(test, 510), (Hey, 362), ("please", 753), (take, 446), (herbert, …

how can I add field in serializer?

Below is my serializer.py file: from rest_framework import serializersclass TaskListSerializer(serializers.Serializer):id = serializers.CharField()user_id = serializers.CharField()status = serializers.…

Read and write a variable in module A from module B

Need a solution or workaround to read and write the variable in moduleA from moduleB please. Here is the code:moduleAimport moduleBvariable = 10def changeVariable():global variablevariable = 20def main…

Iterate through a pandas dataframe to get a specific output [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.Want to improve this question? Add details and clarify the problem by editing this post.Closed 1 year ago.The comm…

Detect if you click inside a box in Python Zelle graphics

I have created a dice betting game. When my code is run, there is a "CLICK TO ROLL" button. Currently, if you click anywhere on the screen, the dice will roll. How can I make it so the progra…

Nested Triangle in Python

My assingmentAt each level the complete triangle for the previous level is placed into an extra outer triangle. The user should be asked to input the two characters to be used and the width of the inne…