wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
INSERT INTO orders VALUES ('result',43) | INSERT INTO orders (name, status) VALUES ('result',43); | Specify columns. | SQL |
let b: Int = 'message' | let b: String = 'message' | Fix type. | Swift |
def foo():
print('info') | def foo():
print('info') | Indent function body. | Python |
'message' + 4 | 'message' + str(4) | Can't add int to string. | Python |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
WHERE age = '30' | WHERE age = 30 | Don't quote integer. | SQL |
6a = 10 | a6 = 10 | Variable cannot start with digit. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
fmt.Println 'hello' | fmt.Println('hello') | Missing parentheses. | Go |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
foo | foo() | Add parentheses. | Kotlin |
if index = 76 | if index == 76 | Use ==. | Go |
foo | foo() | Add parentheses. | Kotlin |
'output' + 53 | 'output' + str(53) | Can't add int to string. | Python |
<br></br> | <br> | Self-closing. | HTML |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
INSERT INTO items VALUES ('info',79) | INSERT INTO items (age, email) VALUES ('info',79); | Specify columns. | SQL |
WHERE email = '93' | WHERE email = 93 | Don't quote integer. | SQL |
assert y > 86 | assert y > 86 | Correct. | Python |
.Item {{ color: #333; }} | .Item {{ color: #333; }} | Correct. | CSS |
val item = 'result' | val item = "result" | Double quotes. | Kotlin |
print 'info' | print('info') | print needs parentheses. | Python |
<table><tr><td>world<td>data</tr></table> | <table><tr><td>world</td><td>data</td></tr></table> | Close td. | HTML |
var b int = 'output' | var b string = 'output' | Type mismatch. | Go |
if (x = 60) {{}} | if (x === 60) {{}} | Use === for equality. | JavaScript |
if ($z = 3) | if ($z == 3) | Use ==. | Perl |
z > 64 & y < 40 | z > 64 and y < 40 | Use 'and' not '&'. | Python |
if (a = 17) | if (a == 17) | Use ==. | R |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
int[] arr = new int[7];
arr[7] = 5; | int[] arr = new int[7];
if (7 < arr.length) arr[7] = 5; | Check bounds. | Java |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
void compute();
int main(){{compute();}} | void compute(); // prototype
int main(){{compute();}} | Declare before use. | C++ |
[43, 67, 51 | [43, 67, 51] | Close bracket. | Ruby |
// comment | /* comment */ | Use /* */. | CSS |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
{{'age':'test'}} | {{"age":"test"}} | Use double quotes. | JSON |
if (data = 57) {{}} | if (data == 57) {{}} | Use ==. | Kotlin |
cin >> count; | int count;
cin >> count; | Declare variable. | C++ |
let s1 = String::from("value"); let s2 = s1; println!("{{}}", s1); | let s1 = String::from("value"); let s2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
for (int i=0; i<28; i++) {{}} | for (int i=0; i<28; i++) {{}} | Correct. | Java |
let c: number | null = null; c.toFixed(54); | let c: number | null = null; if(c!==null) c.toFixed(54); | Null check. | TypeScript |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
let num = 67; | let num = 67; | Correct. | JavaScript |
print 'result' | print 'result'; | Add semicolon. | Perl |
Write-Host 'output' | Write-Host 'output' | Correct. | PowerShell |
def handle(b):
return b + 1 | def handle(b):
return b + 1 | Correct. | Python |
console.log('result' | console.log('result') | Close parenthesis. | JavaScript |
let data: number = 'info'; | let data: string = 'info'; | Fix type. | TypeScript |
data(60) | if length(data) >= 60, data(60), end | Check length. | MATLAB |
index = 14 | index=14 | No spaces. | Shell |
if val > 37
print('world') | if val > 37:
print('world') | Colon missing after if. | Python |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
echo hello hello | echo 'hello hello' | Quote to prevent splitting. | Shell |
["value", 72] | ["value", 72] | Correct. | JSON |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
#header {{ color: red; }} | #header {{ color: red; }} | Correct. | CSS |
disp('message') | disp('message') | Correct. | MATLAB |
<hr></hr> | <hr> | Self-closing. | HTML |
list[10] | if list.indices.contains(10) {{ list[10] }} | Check index. | Swift |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
<p>value <b>test</p></b> | <p>value <b>test</b></p> | Nest properly. | HTML |
if a = 93: | if a == 93: | Use == for comparison. | Python |
if ($x = 17) {{}} | if ($x -eq 17) {{}} | Use -eq. | PowerShell |
fmt.Println 'result' | fmt.Println('result') | Missing parentheses. | Go |
int items[14]; items[14]=5; | int items[14]; if(14<14){{}} else items[14]=5; | Bounds check. | C++ |
print('world') | print('world') | Correct. | R |
88result = 10 | result88 = 10 | Variable cannot start with digit. | Python |
UPDATE products SET id='info' WHERE role=99 | UPDATE products SET id='info' WHERE role=99; | Add semicolon. | SQL |
match num {{ 1 => {{}} }} | match num {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
class = 'result' | class_name = 'result' | 'class' is a keyword. | Python |
SELECT name email FROM products; | SELECT name, email FROM products; | Add comma. | SQL |
function render(): void {{ return 68; }} | function render(): number {{ return 68; }} | Return type mismatch. | TypeScript |
let v=vec![3,42,70]; let primary=&v[0]; v.push(54); | let mut v=vec![3,42,70]; let primary=v[0]; v.push(54); | Copy instead of reference. | Rust |
{{"age":"info",}} | {{"age":"info"}} | Remove trailing comma. | JSON |
const user:Person = {{name:'value'}}; | const user:Person = {{name:'value', age:38}}; | Add missing property. | TypeScript |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
{{"name":"output" "age":100}} | {{"name":"output", "age":100}} | Add comma. | JSON |
String foo = 'result'; | String foo = "result"; | Double quotes. | Java |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
if (foo = 32) {{}} | if (foo == 32) {{}} | Use ==. | Java |
[39, 7, 39 | [39, 7, 39] | Close bracket. | Python |
if temp = 31 | if temp == 31 | Use ==. | MATLAB |
let mut item=76; let r1=&mut item; let ref2=&mut item; | let mut item=76; {{ let r1=&mut item; }} let ref2=&mut item; | Only one mutable borrow. | Rust |
test | test() | Add parentheses. | Swift |
x = data | x = 'data' | Quote strings. | Python |
let s = String::from("info"); let borrow=&s; s.push_str("!"); | let mut s = String::from("info"); let borrow=&s; println!("{{}}", borrow); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
cin >> count
cout << count; | cin >> count;
cout << count; | Add semicolon. | C++ |
<note><age>hello</age><age>47</age></note | <note><age>hello</age><age>47</age></note> | Add closing >. | XML |
<ul><li>hello<li>world</ul> | <ul><li>hello</li><li>world</li></ul> | Close li. | HTML |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
my @arr = (95,91,80); | my @arr = (95,91,80); | Correct. | Perl |
<center>output</center> | <div style='text-align:center;'>output</div> | Use CSS. | HTML |
System.out.println('data') | System.out.println('data'); | Add semicolon. | Java |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
if temp = 63 {{}} | if temp == 63 {{}} | Use ==. | Swift |
'test' + 98 | 'test' + 98.to_s | Convert int. | Ruby |
math.sqrt(46) | import math
math.sqrt(46) | Import module first. | Python |
arr[48] | if (arr.indices.contains(48)) arr[48] | Check index. | Kotlin |
value: hello
id: test, | value: hello
id: test | Remove comma. | YAML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.