Die Suche ergab 7 Treffer
- Sonntag 1. Mai 2022, 15:49
- Forum: Codesnippets
- Thema: String komplett umdrehen
- Antworten: 8
- Zugriffe: 14874
Re: String komplett umdrehen
Deine Ursprungsfrage war einen String "umzudrehen". Dies wurde Dir auch gezeigt. Was Du aber möchtest ist wohl etwas anderes, wie sich nun herausstellt:
Du möchtest die einzelnen Wörter in einem String "reversen", dabei aber die genaue Zahl trennender Leerzeichen beibehalten. Falls das nun ...
- Sonntag 1. Mai 2022, 14:23
- Forum: Codesnippets
- Thema: String komplett umdrehen
- Antworten: 8
- Zugriffe: 14874
Re: String komplett umdrehen
Hey danke schonmal also.
Ich erwarte das hier : "This is an example!" ==> "sihT si na !elpmaxe"
"double spaces" ==> "elbuod secaps"
" d c b a " ==> " a b c d"
"elppa" ==> "apple"
letzteres gibt er auch richtig wieder, aber sobald Leerzeichen enthalten sind kriegt er es nicht mehr hin ...
Ich erwarte das hier : "This is an example!" ==> "sihT si na !elpmaxe"
"double spaces" ==> "elbuod secaps"
" d c b a " ==> " a b c d"
"elppa" ==> "apple"
letzteres gibt er auch richtig wieder, aber sobald Leerzeichen enthalten sind kriegt er es nicht mehr hin ...
- Sonntag 1. Mai 2022, 11:44
- Forum: Codesnippets
- Thema: String komplett umdrehen
- Antworten: 8
- Zugriffe: 14874
String komplett umdrehen
Hey ich will eine Funktion erstellen um einen String komplett umzudrehen, also Zeichen für Zeichen. Ich bin mir so sicher, dass mein Code richtig ist. Was übersehe ich? Liegt es am Leerzeichen?
def reverse_words(text):
stringlength = len(text)
slicedstring = text[stringlength::-1]
return ...
def reverse_words(text):
stringlength = len(text)
slicedstring = text[stringlength::-1]
return ...
- Donnerstag 28. April 2022, 22:46
- Forum: Tkinter
- Thema: Hintergrundfarbe Button
- Antworten: 5
- Zugriffe: 2669
Re: Hintergrundfarbe Button
Hey danke für die Antworten. Ich hangel mich an einem Online-Tutorial entlang. Das sollte nur dazu dienen bisschen was zu lernen!
LG
LG
- Donnerstag 28. April 2022, 21:01
- Forum: Tkinter
- Thema: Hintergrundfarbe Button
- Antworten: 5
- Zugriffe: 2669
Hintergrundfarbe Button
import tkinter as tk
def grad_nach_kelvin():
grad = int(eingabefeld_wert.get())
kelvin = grad + 273
textausgabe = tk.Label(root, text=kelvin, bg="yellow")
textausgabe.pack()
root = tk.Tk()
eingabefeld_wert = tk.StringVar()
eingabefeld = tk.Entry(root, textvariable=eingabefeld_wert ...
def grad_nach_kelvin():
grad = int(eingabefeld_wert.get())
kelvin = grad + 273
textausgabe = tk.Label(root, text=kelvin, bg="yellow")
textausgabe.pack()
root = tk.Tk()
eingabefeld_wert = tk.StringVar()
eingabefeld = tk.Entry(root, textvariable=eingabefeld_wert ...
- Mittwoch 27. April 2022, 15:51
- Forum: Codesnippets
- Thema: Globale Variable nicht anerkannt?
- Antworten: 4
- Zugriffe: 8595
Re: Globale Variable nicht anerkannt?
variable = "Inhalt außerhalb gesetzt"
def grundfunktion():
variable = "Inhalt innerhalb gesetzt"
def fkt_local():
variable = "Inhalt innerhalb local"
def fkt_nonlocal():
nonlocal variable
variable = "Inhalt innerhalb nonlocal"
def fkt_global():
global variable
variable = "Inhalt ...
- Mittwoch 27. April 2022, 09:22
- Forum: Codesnippets
- Thema: Globale Variable nicht anerkannt?
- Antworten: 4
- Zugriffe: 8595
Globale Variable nicht anerkannt?
def grundfunktion():
variable = "Inhalt innerhalb gesetzt"
def fkt_local():
variable = "Inhalt innerhalb local"
def fkt_nonlocal():
nonlocal variable
variable = "Inhalt innerhalb nonlocal"
def fkt_global():
global variable
variable = "Inhalt innerhalb global"
print("2. in Fkt ...
variable = "Inhalt innerhalb gesetzt"
def fkt_local():
variable = "Inhalt innerhalb local"
def fkt_nonlocal():
nonlocal variable
variable = "Inhalt innerhalb nonlocal"
def fkt_global():
global variable
variable = "Inhalt innerhalb global"
print("2. in Fkt ...
