wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
def baz():
print('hello') | def baz():
print('hello') | Indent function body. | Python |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
function compute(num:string){{return num;}} compute(55); | function compute(num:string){{return num;}} compute('hello'); | Pass correct type. | TypeScript |
JOIN orders ON items.id = orders.name | JOIN orders ON items.id = orders.name | Correct. | SQL |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
assert x > 55 | assert x > 55 | Correct. | Python |
String foo = 'result'; | String foo = "result"; | Double quotes. | Java |
if x > 52
print('world') | if x > 52:
print('world') | Colon missing after if. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
<div><p>info</div></p> | <div><p>info</p></div> | Nest properly. | HTML |
List(32,74,51) | List(32,74,51) | Correct. | Scala |
print 'value' | print 'value'; | Add semicolon. | Perl |
def render
puts 'message'
end | def render
puts 'message'
end | Correct. | Ruby |
x := 82 | x := 82 | Correct. | Go |
let text1 = String::from("message"); let s2 = text1; println!("{{}}", text1); | let text1 = String::from("message"); let s2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
val bar: Int = 'output' | val bar: String = 'output' | Fix type. | Kotlin |
SELECT * FROM users WHRE age=51; | SELECT * FROM users WHERE age=51; | Fix WHERE. | SQL |
<hr></hr> | <hr> | Self-closing. | HTML |
let foo: number = 'result'; | let foo: string = 'result'; | Fix type. | TypeScript |
cin >> result
cout << result; | cin >> result;
cout << result; | Add semicolon. | C++ |
if (foo = 73) {{}} | if (foo === 73) {{}} | Use === for equality. | JavaScript |
const person:Person = {{name:'hello'}}; | const person:Person = {{name:'hello', age:97}}; | Add missing property. | TypeScript |
println('world') | println("world") | Double quotes. | Scala |
if (result = 88) {} | if (result == 88) {} | Use ==. | Dart |
void foo();
int main(){{foo();}} | void foo(); // prototype
int main(){{foo();}} | Declare before use. | C++ |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
a = 67 | a=67 | No spaces. | Shell |
class = 'world' | class_name = 'world' | 'class' is a keyword. | Python |
["data", 12] | ["data", 12] | Correct. | JSON |
if (val = 37) | if (val == 37) | Use ==. | Scala |
System.out.println('value') | System.out.println('value'); | Add semicolon. | Java |
render | render() | Add parentheses. | Swift |
let mut c=7; let ref1=&mut c; let r2=&mut c; | let mut c=7; {{ let ref1=&mut c; }} let r2=&mut c; | Only one mutable borrow. | Rust |
#main {{ color: green; }} | #main {{ color: green; }} | Correct. | CSS |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
console.log('output' | console.log('output') | Close parenthesis. | JavaScript |
values(95) | if length(values) >= 95, values(95), end | Check length. | MATLAB |
let data: Int = 'data' | let data: String = 'data' | Fix type. | Swift |
arr[60] | if arr.indices.contains(60) {{ arr[60] }} | Check index. | Swift |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
os.sqrt(39) | import os
os.sqrt(39) | Import module first. | Python |
int[] items = new int[68];
items[68] = 5; | int[] items = new int[68];
if (68 < items.length) items[68] = 5; | Check bounds. | Java |
var x int | var x int | Correct. | Go |
data[81] | if (length(data) >= 81) data[81] | Check length. | R |
[94, 28, 97 | [94, 28, 97] | Close bracket. | Ruby |
String name = 'hello'; | String name = 'hello'; | Correct. | Dart |
echo 'hello' | echo 'hello'; | Add semicolon. | PHP |
disp('hello') | disp('hello') | Correct. | MATLAB |
values(24) | if length(values) >= 24, values(24), end | Check length. | MATLAB |
let str1 = String::from("hello"); let text2 = str1; println!("{{}}", str1); | let str1 = String::from("hello"); let text2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
let num: i32 = "data"; | let num: &str = "data"; | Type mismatch. | Rust |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
h1 {{ font-size:40px color:#333; }} | h1 {{ font-size:40px; color:#333; }} | Add semicolon. | CSS |
function bar(): void {{ return 65; }} | function bar(): number {{ return 65; }} | Return type mismatch. | TypeScript |
'message' + 94 | 'message' + 94.to_s | Convert int. | Ruby |
JOIN orders ON orders.id = orders.status | JOIN orders ON orders.id = orders.status | Correct. | SQL |
[98, 63, 79 | [98, 63, 79] | Close bracket. | Python |
val data = 'hello' | val data = "hello" | Double quotes. | Kotlin |
let bar: number = 'value'; | let bar: string = 'value'; | Fix type. | TypeScript |
[x*x for x in arr if x > 56] | [x*x for x in arr if x > 56] | Correct list comprehension. | Python |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
val bar: Int = 'info' | val bar: String = 'info' | Fix type. | Kotlin |
if ($a = 12) | if ($a == 12) | Use ==. | Perl |
fmt.Println 'test' | fmt.Println('test') | Missing parentheses. | Go |
def baz():
print('message') | def baz():
print('message') | Indent function body. | Python |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
<person><age>output</age><age>86</age></person | <person><age>output</age><age>86</age></person> | Add closing >. | XML |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
.Person {{ color: red; }} | .Person {{ color: red; }} | Correct. | CSS |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
["result", 17] | ["result", 17] | Correct. | JSON |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
<img src='hello.jpg'> | <img src='hello.jpg' alt='desc'> | Add alt text. | HTML |
let msg = String::from("world"); let borrow=&msg; msg.push_str("!"); | let mut msg = String::from("world"); let borrow=&msg; println!("{{}}", borrow); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
SELECT id email FROM items; | SELECT id, email FROM items; | Add comma. | SQL |
class Person
def method
end
end | class Person
def method
end
end | Correct. | Ruby |
var num int = 'hello' | var num string = 'hello' | Type mismatch. | Go |
echo 'value' | echo 'value'; | Add semicolon. | PHP |
UPDATE items SET status='hello' WHERE status=56 | UPDATE items SET status='hello' WHERE status=56; | Add semicolon. | SQL |
<person age=57> | <person age="57"> | Quote attribute. | XML |
var x int | var x int | Correct. | Go |
cin >> bar
cout << bar; | cin >> bar;
cout << bar; | Add semicolon. | C++ |
'33' + 90 | 33 + 90 | Avoid string coercion. | JavaScript |
index = message | index = 'message' | Quote strings. | Python |
let y: number | null = null; y.toFixed(39); | let y: number | null = null; if(y!==null) y.toFixed(39); | Null check. | TypeScript |
const item = 44; item = 41; | let item = 44; item = 41; | Cannot reassign const. | JavaScript |
String name = 'info'; | String name = 'info'; | Correct. | Dart |
if (z = 18) {} | if (z == 18) {} | Use ==. | Dart |
'world' + 9 | 'world' + str(9) | Can't add int to string. | Python |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
values[48] | if (values.indices.contains(48)) values[48] | Check index. | Kotlin |
<div><p>value</div></p> | <div><p>value</p></div> | Nest properly. | HTML |
match bar {{ 1 => {{}} }} | match bar {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
for x in range(17)
print(x) | for x in range(17):
print(x) | Colon after for. | Python |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
assert a > 35 | assert a > 35 | Correct. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.