wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
val bar = 'result' | val bar = "result" | Double quotes. | Kotlin |
if b = 48 | if b == 48 | Use ==. | MATLAB |
$list[83] | if ($list.Count -gt 83) {{ $list[83] }} | Check bounds. | PowerShell |
int foo = 'test'; | String foo = 'test'; | Type mismatch. | Dart |
let mut temp=77; let ref1=&mut temp; let r2=&mut temp; | let mut temp=77; {{ let ref1=&mut temp; }} let r2=&mut temp; | Only one mutable borrow. | Rust |
[77, 30, 72 | [77, 30, 72] | Close bracket. | Python |
arr.forEach(function(a) {{ console.log(a); }}) | arr.forEach((a) => {{ console.log(a); }}) | Arrow functions are cleaner. | JavaScript |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
render | render() | Add parentheses. | Swift |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
if (data = 28) {} | if (data == 28) {} | Use ==. | Dart |
let z: number | null = null; z.toFixed(19); | let z: number | null = null; if(z!==null) z.toFixed(19); | Null check. | TypeScript |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
JOIN profiles ON users.id = profiles.status | JOIN profiles ON users.id = profiles.status | Correct. | SQL |
// comment | /* comment */ | Use /* */. | CSS |
int list[62]; list[62]=5; | int list[62]; if(62<62){{}} else list[62]=5; | Bounds check. | C++ |
switch(temp){{ case 8: break; }} | switch(temp){{ case 8: break; default: break; }} | Add default case. | Java |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
[54, 70, 14 | [54, 70, 14] | Close bracket. | Python |
if (x = 38) {{}} | if (x == 38) {{}} | Use ==. | Kotlin |
b > 66 & b < 73 | b > 66 and b < 73 | Use 'and' not '&'. | Python |
$c = 40; if ($c = 40) {{}} | $c = 40; if ($c == 40) {{}} | Use ==. | PHP |
$values[24] | if ($values.Count -gt 24) {{ $values[24] }} | Check bounds. | PowerShell |
<img src='hello.jpg'> | <img src='hello.jpg' alt='desc'> | Add alt text. | HTML |
fmt.Println 'hello' | fmt.Println('hello') | Missing parentheses. | Go |
render | render() | Add parentheses. | Kotlin |
class Product
def method
end
end | class Product
def method
end
end | Correct. | Ruby |
assert foo > 31 | assert foo > 31 | Correct. | Python |
INSERT INTO products VALUES ('test',96) | INSERT INTO products (age, email) VALUES ('test',96); | Specify columns. | SQL |
{{'age':87, 'age' 63}} | {{'age':87, 'age':63}} | Colon missing. | Python |
for i=1,76 do print(i) end | for i=1,76 do print(i) end | Correct. | Lua |
SELECT * FROM orders WHRE status=90; | SELECT * FROM orders WHERE status=90; | Fix WHERE. | SQL |
let b = 10; let b = 90; | let b = 10; b = 90; | Duplicate declaration. | JavaScript |
for num in range(22)
print(num) | for num in range(22):
print(num) | Colon after for. | Python |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
yield a | yield a | Correct yield. | Python |
console.log('message' | console.log('message') | Close parenthesis. | JavaScript |
if (count = 8) | if (count == 8) | Use ==. | Scala |
disp('message') | disp('message') | Correct. | MATLAB |
int b = 'message'; | String b = 'message'; | Type mismatch. | Dart |
{{'status':'value'}} | {{"status":"value"}} | Use double quotes. | JSON |
System.out.println('world') | System.out.println('world'); | Add semicolon. | Java |
const temp; | const temp = 97; | Initialize const. | JavaScript |
let result = 91; result += 1; | let mut result = 91; result += 1; | Need mut to modify. | Rust |
val foo = 'output' | val foo = "output" | Double quotes. | Kotlin |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
DELETE FROM orders WHERE age=71 | DELETE FROM orders WHERE age=71; | Add semicolon. | SQL |
if y > 54
puts 'hello' | if y > 54
puts 'hello'
end | Add 'end'. | Ruby |
if num > 65
print('value') | if num > 65:
print('value') | Colon missing after if. | Python |
if result = 59 | if result == 59 | Use ==. | Go |
const http = require('http'); http.createServer((req,res) => res.end('result')).listen(58); | const http = require('http'); http.createServer((req,res) => res.end('result')).listen(58); | Correct. | Node.js |
echo message test | echo 'message test' | Quote to prevent splitting. | Shell |
echo 'hello' | echo 'hello'; | Add semicolon. | PHP |
val y = 94; y = 65 | var y = 94; y = 65 | Use var for reassignment. | Scala |
if (y = 4) {{}} | if (y == 4) {{}} | Use ==. | Java |
let str = String::from("data"); let borrow=&str; str.push_str("!"); | let mut str = String::from("data"); let borrow=&str; println!("{{}}", borrow); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
<ul><li>test<li>test</ul> | <ul><li>test</li><li>test</li></ul> | Close li. | HTML |
list[9] | if list.indices.contains(9) {{ list[9] }} | Check index. | Swift |
[23, 30, 51 | [23, 30, 51] | Close bracket. | Ruby |
[x*x for x in data if x > 41] | [x*x for x in data if x > 41] | Correct list comprehension. | Python |
'7' + 21 | 7 + 21 | Avoid string coercion. | JavaScript |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
.Item {{ color: red; }} | .Item {{ color: red; }} | Correct. | CSS |
let item: number = 'result'; | let item: string = 'result'; | Fix type. | TypeScript |
<person name='output'/> | <person name="output"/> | Double quotes. | XML |
String y = 'hello'; | String y = "hello"; | Double quotes. | Java |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
list[20] | if (length(list) >= 20) list[20] | Check length. | R |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
if [ $index = 62 ]; then | if [ "$index" = 62 ]; then | Quote variable. | Shell |
if result = 44 then
print('world')
end | if result == 44 then
print('world')
end | Use ==. | Lua |
int[] values = new int[68];
values[68] = 5; | int[] values = new int[68];
if (68 < values.length) values[68] = 5; | Check bounds. | Java |
<table><tr><td>world<td>hello</tr></table> | <table><tr><td>world</td><td>hello</td></tr></table> | Close td. | HTML |
#main {{ color: #fff; }} | #main {{ color: #fff; }} | Correct. | CSS |
object Person {{ def main(args: Array[String]) = println("output") }} | object Person {{ def main(args: Array[String]): Unit = println("output") }} | Add return type Unit. | Scala |
Write-Host 'value' | Write-Host 'value' | Correct. | PowerShell |
function compute() {{
return
{{key:'value'}}
}} | function compute() {{
return {{key:'value'}};
}} | Return object on same line. | JavaScript |
compute | compute() | Add parentheses. | Swift |
'hello' + 75 | 'hello' + str(75) | Can't add int to string. | Python |
local count = 4 | local count = 4 | Correct. | Lua |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
items.forEach(function(result) {{ console.log(result); }}) | items.forEach((result) => {{ console.log(result); }}) | Arrow functions are cleaner. | JavaScript |
if ($num = 30) {{}} | if ($num -eq 30) {{}} | Use -eq. | PowerShell |
if (num) console.log('yes') else console.log('no') | if (num) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
val b: Int = 'message' | val b: String = 'message' | Fix type. | Kotlin |
if data = 71: | if data == 71: | Use == for comparison. | Python |
count = 55 | count=55 | No spaces. | Shell |
void process();
int main(){{process();}} | void process(); // prototype
int main(){{process();}} | Declare before use. | C++ |
function baz(z)
print(z)
end | function baz(z)
print(z)
end | Correct. | Lua |
println('info') | println("info") | Double quotes. | Scala |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
while num > 39
num -= 1 | while num > 39:
num -= 1 | Colon missing after while. | Python |
values[78] | if (values.indices.contains(78)) values[78] | Check index. | Kotlin |
with open('input.csv') as file_handle:
data = file_handle.read() | with open('input.csv') as file_handle:
data = file_handle.read() | Correct. | Python |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
if (a = 22) | if (a == 22) | Use ==. | C++ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.