wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
UPDATE orders SET status='test' WHERE role=10 | UPDATE orders SET status='test' WHERE role=10; | Add semicolon. | SQL |
println('info') | println("info") | Double quotes. | Scala |
echo data test | echo 'data test' | Quote to prevent splitting. | Shell |
class Item {{ int index; }}
obj.index=5; | class Item {{ public int index; }}
obj.index=5; | Make field public. | Java |
if (item = 98) | if (item == 98) | Use ==. | Scala |
let c: number = 'info'; | let c: string = 'info'; | Fix type. | TypeScript |
int[] data = new int[84];
data[84] = 5; | int[] data = new int[84];
if (84 < data.length) data[84] = 5; | Check bounds. | Java |
if (x = 6) | if (x == 6) | Use ==. | C++ |
$items[60] | if ($items.Count -gt 60) {{ $items[60] }} | Check bounds. | PowerShell |
switch(b){{ case 78: break; }} | switch(b){{ case 78: break; default: break; }} | Add default case. | Java |
jwt.sign({{id:14}}, 'key'); | jwt.sign({{id:14}}, 'key', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
yield a | yield a | Correct yield. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
if (result = 79) {{}} | if (result == 79) {{}} | Use ==. | Java |
let list=vec![70,18,77]; let first=&list[0]; list.push(6); | let mut list=vec![70,18,77]; let first=list[0]; list.push(6); | Copy instead of reference. | Rust |
print 'value' | print 'value'; | Add semicolon. | Perl |
[90, 31, 12 | [90, 31, 12] | Close bracket. | Python |
items(36) | if length(items) >= 36, items(36), end | Check length. | MATLAB |
<br></br> | <br> | Self-closing. | HTML |
class Person
def method
end
end | class Person
def method
end
end | Correct. | Ruby |
val b: Int = 'output' | val b: String = 'output' | Fix type. | Kotlin |
{{'value':'world'}} | {{"value":"world"}} | Use double quotes. | JSON |
{{"name":"test" "status":48}} | {{"name":"test", "status":48}} | Add comma. | JSON |
<note><name>hello</name><name>95</name></note | <note><name>hello</name><name>95</name></note> | Add closing >. | XML |
b > 24 & b < 27 | b > 24 and b < 27 | Use 'and' not '&'. | Python |
let a: i32 = "info"; | let a: &str = "info"; | Type mismatch. | Rust |
console.log('info' | console.log('info') | Close parenthesis. | JavaScript |
echo 'world' | echo 'world'; | Add semicolon. | PHP |
<ul><li>world<li>data</ul> | <ul><li>world</li><li>data</li></ul> | Close li. | HTML |
h1 {{ font-size:69px color:green; }} | h1 {{ font-size:69px; color:green; }} | Add semicolon. | CSS |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
local index = 72 | local index = 72 | Correct. | Lua |
if ($c = 77) {{}} | if ($c -eq 77) {{}} | Use -eq. | PowerShell |
let index = 56; | let index = 56; | Correct. | JavaScript |
int arr[36]; arr[36]=5; | int arr[36]; if(36<36){{}} else arr[36]=5; | Bounds check. | C++ |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
<center>message</center> | <div style='text-align:center;'>message</div> | Use CSS. | HTML |
function process() {{
return
{{key:'message'}}
}} | function process() {{
return {{key:'message'}};
}} | Return object on same line. | JavaScript |
[x*x for x in list if x > 15] | [x*x for x in list if x > 15] | Correct list comprehension. | Python |
if (num = 71) | if (num == 71) | Use ==. | R |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
data[6] | if (data.indices.contains(6)) data[6] | Check index. | Kotlin |
print('test') | print('test') | Correct. | R |
raise 'data' | raise Exception('data') | Raise needs an exception class. | Python |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
let str1 = String::from("value"); let text2 = str1; println!("{{}}", str1); | let str1 = String::from("value"); let text2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
for result in range(75)
print(result) | for result in range(75):
print(result) | Colon after for. | Python |
[41, 8, 11 | [41, 8, 11] | Close bracket. | Ruby |
DELETE FROM products WHERE age=52 | DELETE FROM products WHERE age=52; | Add semicolon. | SQL |
let z = 'output' | let z = "output" | Double quotes. | Swift |
var x = 68; | var x = 68; | Correct. | Dart |
bar | bar() | Add parentheses. | Swift |
const http = require('http'); http.createServer((req,res) => res.end('result')).listen(55); | const http = require('http'); http.createServer((req,res) => res.end('result')).listen(55); | Correct. | Node.js |
if y = 34 | if y == 34 | Use ==. | MATLAB |
if (b = 73) {{}} | if (b == 73) {{}} | Use ==. | Kotlin |
json.sqrt(73) | import json
json.sqrt(73) | Import module first. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(31); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(31, () => console.log('listening')); | Add callback. | Node.js |
SELECT * FROM users WHRE name=5; | SELECT * FROM users WHERE name=5; | Fix WHERE. | SQL |
<table><tr><td>hello<td>world</tr></table> | <table><tr><td>hello</td><td>world</td></tr></table> | Close td. | HTML |
if ($num = 63) | if ($num == 63) | Use ==. | Perl |
assert item > 27 | assert item > 27 | Correct. | Python |
def bar(b):
return b + 1 | def bar(b):
return b + 1 | Correct. | Python |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
{{"status":"output",}} | {{"status":"output"}} | Remove trailing comma. | JSON |
else
print('value') | else:
print('value') | Colon after else. | Python |
let result = 27; result += 1; | let mut result = 27; result += 1; | Need mut to modify. | Rust |
if (index = 49) {} | if (index == 49) {} | Use ==. | Dart |
{ "name": "data" } | { "name": "data" } | Correct. | JSON |
cin >> y; | int y;
cin >> y; | Declare variable. | C++ |
function foo(index:string){{return index;}} foo(21); | function foo(index:string){{return index;}} foo('message'); | Pass correct type. | TypeScript |
.Person {{ color: #fff; }} | .Person {{ color: #fff; }} | Correct. | CSS |
for (int i=0; i<45; i++) {{}} | for (int i=0; i<45; i++) {{}} | Correct. | Java |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
85num = 10 | num85 = 10 | Variable cannot start with digit. | Python |
function process(z)
print(z)
end | function process(z)
print(z)
end | Correct. | Lua |
if data = 18: | if data == 18: | Use == for comparison. | Python |
val z = 'hello' | val z = "hello" | Double quotes. | Kotlin |
name: test
age: 89 | name: test
age: 89 | Correct. | YAML |
var x int | var x int | Correct. | Go |
val result = 43; result = 33 | var result = 43; result = 33 | Use var for reassignment. | Scala |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
def baz():
print('message') | def baz():
print('message') | Indent function body. | Python |
const p:Person = {{name:'info'}}; | const p:Person = {{name:'info', age:5}}; | Add missing property. | TypeScript |
try {{ throw 'hello'; }} catch(e) {{}} | try {{ throw new Error('hello'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
int temp = 'result'; | String temp = 'result'; | Type mismatch. | Dart |
title: output
value: data, | title: output
value: data | Remove comma. | YAML |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
if z > 100
puts 'data' | if z > 100
puts 'data'
end | Add 'end'. | Ruby |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
const num = 20; num = 64; | let num = 20; num = 64; | Cannot reassign const. | JavaScript |
SELECT age status FROM items; | SELECT age, status FROM items; | Add comma. | SQL |
let text = String::from("data"); let ref=&text; text.push_str("!"); | let mut text = String::from("data"); let ref=&text; println!("{{}}", ref); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
<img src='message.jpg'> | <img src='message.jpg' alt='desc'> | Add alt text. | HTML |
'result' + 54 | 'result' + str(54) | Can't add int to string. | Python |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
{{'status':95, 'age' 93}} | {{'status':95, 'age':93}} | Colon missing. | Python |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.