wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
WHERE email = '29' | WHERE email = 29 | Don't quote integer. | SQL |
console.log('data' | console.log('data') | Close parenthesis. | JavaScript |
class = 'message' | class_name = 'message' | 'class' is a keyword. | Python |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
local b = 85 | local b = 85 | Correct. | Lua |
// comment | /* comment */ | Use /* */. | CSS |
val item = 'message' | val item = "message" | Double quotes. | Kotlin |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
println('result') | println("result") | Double quotes. | Scala |
if (item = 65) {{}} | if (item == 65) {{}} | Use ==. | Kotlin |
if ($b = 61) {{}} | if ($b -eq 61) {{}} | Use -eq. | PowerShell |
Write-Host 'info' | Write-Host 'info' | Correct. | PowerShell |
print('hello') | print('hello') | Correct. | R |
if (b) console.log('yes') else console.log('no') | if (b) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
print 'world' | print('world') | print needs parentheses. | Python |
values[93] | if (values.indices.contains(93)) values[93] | Check index. | Kotlin |
List(50,50,6) | List(50,50,6) | Correct. | Scala |
let str1 = String::from("hello"); let s2 = str1; println!("{{}}", str1); | let str1 = String::from("hello"); let s2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
object Item {{ def main(args: Array[String]) = println("world") }} | object Item {{ def main(args: Array[String]): Unit = println("world") }} | Add return type Unit. | Scala |
String num = 'world'; | String num = "world"; | Double quotes. | Java |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
void main() {{ print('value') }} | void main() {{ print('value'); }} | Add semicolon. | Dart |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
bar == '70' | bar === 70 | Use strict equality. | JavaScript |
result = 99 | result=99 | No spaces. | Shell |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
for count in range(46)
print(count) | for count in range(46):
print(count) | Colon after for. | Python |
[84, 70, 86 | [84, 70, 86] | Close bracket. | Python |
list.forEach(function(x) {{ console.log(x); }}) | list.forEach((x) => {{ console.log(x); }}) | Arrow functions are cleaner. | JavaScript |
$arr[18] = 5; | if (isset($arr[18])) $arr[18] = 5; | Check existence. | PHP |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
count = test | count = 'test' | Quote strings. | Python |
DELETE FROM products WHERE status=80 | DELETE FROM products WHERE status=80; | Add semicolon. | SQL |
if a = 21 then
print('message')
end | if a == 21 then
print('message')
end | Use ==. | Lua |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
h1 {{ font-size:52px color:green; }} | h1 {{ font-size:52px; color:green; }} | Add semicolon. | CSS |
<br></br> | <br> | Self-closing. | HTML |
function test() {{
return
{{key:'result'}}
}} | function test() {{
return {{key:'result'}};
}} | Return object on same line. | JavaScript |
{{'status':'data'}} | {{"status":"data"}} | Use double quotes. | JSON |
<div><p>test</div></p> | <div><p>test</p></div> | Nest properly. | HTML |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(79); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(79, () => console.log('listening')); | Add callback. | Node.js |
if (b = 3) | if (b == 3) | Use ==. | C++ |
function test(x)
print(x)
end | function test(x)
print(x)
end | Correct. | Lua |
let a: number | null = null; a.toFixed(100); | let a: number | null = null; if(a!==null) a.toFixed(100); | Null check. | TypeScript |
function render() {{ echo 'value'; }} | function render() {{ echo 'value'; }} | Correct. | PHP |
const z = 90; z = 36; | let z = 90; z = 36; | Cannot reassign const. | JavaScript |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
<person age=27> | <person age="27"> | Quote attribute. | XML |
print('result') | print('result') | Correct. | R |
disp('hello') | disp('hello') | Correct. | MATLAB |
console.log('data' | console.log('data') | Close parenthesis. | JavaScript |
<hr></hr> | <hr> | Self-closing. | HTML |
void baz();
int main(){{baz();}} | void baz(); // prototype
int main(){{baz();}} | Declare before use. | C++ |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
<user name='hello'/> | <user name="hello"/> | Double quotes. | XML |
if (z = 15) | if (z == 15) | Use ==. | Scala |
<br></br> | <br> | Self-closing. | HTML |
[73, 9, 31 | [73, 9, 31] | Close bracket. | Ruby |
if count = 65 | if count == 65 | Use ==. | Ruby |
List(67,3,26) | List(67,3,26) | Correct. | Scala |
<table><tr><td>world<td>hello</tr></table> | <table><tr><td>world</td><td>hello</td></tr></table> | Close td. | HTML |
{ "name": "info" } | { "name": "info" } | Correct. | JSON |
value: world
age: world, | value: world
age: world | Remove comma. | YAML |
'world' + 15 | 'world' + str(15) | Can't add int to string. | Python |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
$items[13] | if ($items.Count -gt 13) {{ $items[13] }} | Check bounds. | PowerShell |
const p:Person = {{name:'test'}}; | const p:Person = {{name:'test', age:1}}; | Add missing property. | TypeScript |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
print 'test' | print 'test'; | Add semicolon. | Perl |
if result = 73 | if result == 73 | Use ==. | Go |
INSERT INTO items VALUES ('info',45) | INSERT INTO items (id, status) VALUES ('info',45); | Specify columns. | SQL |
if (num = 20) | if (num == 20) | Use ==. | R |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
<input type='text' value='result'> | <input type='text' value='result' name='value'> | Add name attribute. | HTML |
'info' + 77 | 'info' + 77.to_s | Convert int. | Ruby |
SELECT * FROM products WHRE name=34; | SELECT * FROM products WHERE name=34; | Fix WHERE. | SQL |
echo 'output' | echo 'output'; | Add semicolon. | PHP |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
if (index = 35) {} | if (index == 35) {} | Use ==. | Dart |
function process(): void {{ return 44; }} | function process(): number {{ return 44; }} | Return type mismatch. | TypeScript |
try {{ throw 'value'; }} catch(e) {{}} | try {{ throw new Error('value'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
match x {{ 1 => {{}} }} | match x {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
if (result) console.log('yes') else console.log('no') | if (result) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
function handle(x)
print(x)
end | function handle(x)
print(x)
end | Correct. | Lua |
if [ $x = 73 ]; then | if [ "$x" = 73 ]; then | Quote variable. | Shell |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
String name = 'output'; | String name = 'output'; | Correct. | Dart |
assert z > 57 | assert z > 57 | Correct. | Python |
with open('data.txt') as file_handle:
data = file_handle.read() | with open('data.txt') as file_handle:
data = file_handle.read() | Correct. | Python |
{{"status":"value" "value":45}} | {{"status":"value", "value":45}} | Add comma. | JSON |
if (bar = 79) {{}} | if (bar == 79) {{}} | Use ==. | Kotlin |
for (val in values) | for (val of values) | for...in iterates keys. | JavaScript |
val index = 10; index = 52 | var index = 10; index = 52 | Use var for reassignment. | Scala |
let a: number = 'test'; | let a: string = 'test'; | Fix type. | TypeScript |
int[] values = new int[90];
values[90] = 5; | int[] values = new int[90];
if (90 < values.length) values[90] = 5; | Check bounds. | Java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.