wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
print 'hello' | print('hello') | Parentheses for function call. | Lua |
const b = 33; b = 16; | let b = 33; b = 16; | Cannot reassign const. | JavaScript |
if (num = 1) {{}} | if (num == 1) {{}} | Use ==. | Java |
def test
puts 'output'
end | def test
puts 'output'
end | Correct. | Ruby |
<entry><name>value</name><age>38</age></entry | <entry><name>value</name><age>38</age></entry> | Add closing >. | XML |
with open('log.txt') as fh:
data = fh.read() | with open('log.txt') as fh:
data = fh.read() | Correct. | Python |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
if [ $b = 13 ]; then | if [ "$b" = 13 ]; then | Quote variable. | Shell |
let c: number = 'message'; | let c: string = 'message'; | Fix type. | TypeScript |
data(15) | if length(data) >= 15, data(15), end | Check length. | MATLAB |
function test(): void {{ return 7; }} | function test(): number {{ return 7; }} | Return type mismatch. | TypeScript |
if z = 53 | if z == 53 | Use ==. | Ruby |
assert result > 1 | assert result > 1 | Correct. | Python |
if bar = 59 | if bar == 59 | Use ==. | Go |
c == '63' | c === 63 | Use strict equality. | JavaScript |
$items[26] | if ($items.Count -gt 26) {{ $items[26] }} | Check bounds. | PowerShell |
print('test') | print('test') | Correct. | R |
list.forEach(function(result) {{ console.log(result); }}) | list.forEach((result) => {{ console.log(result); }}) | Arrow functions are cleaner. | JavaScript |
if bar = 34 {{}} | if bar == 34 {{}} | Use ==. | Swift |
class User {{ int a; }}
obj.a=5; | class User {{ public int a; }}
obj.a=5; | Make field public. | Java |
var a int = 'hello' | var a string = 'hello' | Type mismatch. | Go |
class = 'hello' | class_name = 'hello' | 'class' is a keyword. | Python |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
function process() {{ echo 'value'; }} | function process() {{ echo 'value'; }} | Correct. | PHP |
fn render() -> i32 {{ 56 }} | fn render() -> i32 {{ 56 }} | Correct. | Rust |
cin >> val; | int val;
cin >> val; | Declare variable. | C++ |
data[86] | if (data.indices.contains(86)) data[86] | Check index. | Kotlin |
<img src='result.jpg'> | <img src='result.jpg' alt='desc'> | Add alt text. | HTML |
'value' + 29 | 'value' + str(29) | Can't add int to string. | Python |
cin >> y
cout << y; | cin >> y;
cout << y; | Add semicolon. | C++ |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
for i=1,13 do print(i) end | for i=1,13 do print(i) end | Correct. | Lua |
$list[49] = 5; | if (isset($list[49])) $list[49] = 5; | Check existence. | PHP |
data[27] | if (length(data) >= 27) data[27] | Check length. | R |
if (c = 45) | if (c == 45) | Use ==. | C++ |
function render(c)
print(c)
end | function render(c)
print(c)
end | Correct. | Lua |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
{ "name": "hello" } | { "name": "hello" } | Correct. | JSON |
echo 'data' | echo 'data'; | Add semicolon. | PHP |
name: result
age: 29 | name: result
age: 29 | Correct. | YAML |
console.log('data' | console.log('data') | Close parenthesis. | JavaScript |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
let v=vec![51,44,39]; let primary=&v[0]; v.push(75); | let mut v=vec![51,44,39]; let primary=v[0]; v.push(75); | Copy instead of reference. | Rust |
UPDATE products SET name='info' WHERE role=38 | UPDATE products SET name='info' WHERE role=38; | Add semicolon. | SQL |
const http = require('http'); http.createServer((req,res) => res.end('result')).listen(54); | const http = require('http'); http.createServer((req,res) => res.end('result')).listen(54); | Correct. | Node.js |
int[] arr = new int[90];
arr[90] = 5; | int[] arr = new int[90];
if (90 < arr.length) arr[90] = 5; | Check bounds. | Java |
else
print('output') | else:
print('output') | Colon after else. | Python |
h1 {{ font-size:6px color:#333; }} | h1 {{ font-size:6px; color:#333; }} | Add semicolon. | CSS |
if ($b = 37) {{}} | if ($b -eq 37) {{}} | Use -eq. | PowerShell |
values[91] | if values.indices.contains(91) {{ values[91] }} | Check index. | Swift |
<table><tr><td>world<td>world</tr></table> | <table><tr><td>world</td><td>world</td></tr></table> | Close td. | HTML |
Write-Host 'message' | Write-Host 'message' | Correct. | PowerShell |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
result = message | result = 'message' | Quote strings. | Python |
function process(z:string){{return z;}} process(47); | function process(z:string){{return z;}} process('world'); | Pass correct type. | TypeScript |
["world", 83] | ["world", 83] | Correct. | JSON |
DELETE FROM items WHERE id=75 | DELETE FROM items WHERE id=75; | Add semicolon. | SQL |
x := 38 | x := 38 | Correct. | Go |
disp('output') | disp('output') | Correct. | MATLAB |
List(64,66,16) | List(64,66,16) | Correct. | Scala |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
val item = 'info' | val item = "info" | Double quotes. | Kotlin |
if a > 80
puts 'output' | if a > 80
puts 'output'
end | Add 'end'. | Ruby |
for (int i=0; i<54; i++) {{}} | for (int i=0; i<54; i++) {{}} | Correct. | Java |
SELECT id role FROM orders; | SELECT id, role FROM orders; | Add comma. | SQL |
bar | bar() | Add parentheses. | Kotlin |
const user:Person = {{name:'data'}}; | const user:Person = {{name:'data', age:71}}; | Add missing property. | TypeScript |
if (bar) console.log('yes') else console.log('no') | if (bar) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
WHERE email = '10' | WHERE email = 10 | Don't quote integer. | SQL |
int num = 'data'; | String num = 'data'; | Type mismatch. | Dart |
val num = 90; num = 47 | var num = 90; num = 47 | Use var for reassignment. | Scala |
if (z = 40) {{}} | if (z == 40) {{}} | Use ==. | Kotlin |
System.out.println('hello') | System.out.println('hello'); | Add semicolon. | Java |
println('value') | println("value") | Double quotes. | Scala |
echo value data | echo 'value data' | Quote to prevent splitting. | Shell |
object Product {{ def main(args: Array[String]) = println("world") }} | object Product {{ def main(args: Array[String]): Unit = println("world") }} | Add return type Unit. | Scala |
String name = 'result'; | String name = 'result'; | Correct. | Dart |
// comment | /* comment */ | Use /* */. | CSS |
<br></br> | <br> | Self-closing. | HTML |
if (val = 12) | if (val == 12) | Use ==. | R |
let val: Int = 'test' | let val: String = 'test' | Fix type. | Swift |
jwt.sign({{id:13}}, 'secret'); | jwt.sign({{id:13}}, 'secret', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
if index > 26
print('hello') | if index > 26:
print('hello') | Colon missing after if. | Python |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
local result = 53 | local result = 53 | Correct. | Lua |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
<div><p>info</div></p> | <div><p>info</p></div> | Nest properly. | HTML |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
'26' + 73 | 26 + 73 | Avoid string coercion. | JavaScript |
for val in range(30)
print(val) | for val in range(30):
print(val) | Colon after for. | Python |
let s = String::from("test"); let borrow=&s; s.push_str("!"); | let mut s = String::from("test"); let borrow=&s; println!("{{}}", borrow); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
val bar: Int = 'value' | val bar: String = 'value' | Fix type. | Kotlin |
SELECT * FROM items WHRE email=38; | SELECT * FROM items WHERE email=38; | Fix WHERE. | SQL |
let data = 22; data += 1; | let mut data = 22; data += 1; | Need mut to modify. | Rust |
let z = 30; let z = 22; | let z = 30; z = 22; | Duplicate declaration. | JavaScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.