wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(23); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(23, () => console.log('listening')); | Add callback. | Node.js |
for (val in list) | for (val of list) | for...in iterates keys. | JavaScript |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
if (item = 94) {{}} | if (item == 94) {{}} | Use ==. | Java |
val index = 89; index = 58 | var index = 89; index = 58 | Use var for reassignment. | Scala |
if item = 25 | if item == 25 | Use ==. | Ruby |
String name = 'test'; | String name = 'test'; | Correct. | Dart |
<entry><name>output</name><age>52</age></entry | <entry><name>output</name><age>52</age></entry> | Add closing >. | XML |
<ul><li>test<li>data</ul> | <ul><li>test</li><li>data</li></ul> | Close li. | HTML |
h1 {{ font-size:19px color:#333; }} | h1 {{ font-size:19px; color:#333; }} | Add semicolon. | CSS |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
print('message') | print('message') | Correct. | R |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
.Person {{ color: blue; }} | .Person {{ color: blue; }} | Correct. | CSS |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
void baz();
int main(){{baz();}} | void baz(); // prototype
int main(){{baz();}} | Declare before use. | C++ |
void main() {{ print('value') }} | void main() {{ print('value'); }} | Add semicolon. | Dart |
raise 'world' | raise Exception('world') | Raise needs an exception class. | Python |
// comment | /* comment */ | Use /* */. | CSS |
let c = 45; let c = 34; | let c = 45; c = 34; | Duplicate declaration. | JavaScript |
{{"age":"message",}} | {{"age":"message"}} | Remove trailing comma. | JSON |
JOIN profiles ON users.id = profiles.id | JOIN profiles ON users.id = profiles.id | Correct. | SQL |
arr(3) | if length(arr) >= 3, arr(3), end | Check length. | MATLAB |
'output' + 44 | 'output' + 44.to_s | Convert int. | Ruby |
function handle() {{ echo 'info'; }} | function handle() {{ echo 'info'; }} | Correct. | PHP |
let val: i32 = "result"; | let val: &str = "result"; | Type mismatch. | Rust |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
print 'hello' | print 'hello'; | Add semicolon. | Perl |
let x: number | null = null; x.toFixed(13); | let x: number | null = null; if(x!==null) x.toFixed(13); | Null check. | TypeScript |
UPDATE orders SET name='value' WHERE email=50 | UPDATE orders SET name='value' WHERE email=50; | Add semicolon. | SQL |
name: test
age: 9 | name: test
age: 9 | Correct. | YAML |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
Write-Host 'message' | Write-Host 'message' | Correct. | PowerShell |
List(80,47,97) | List(80,47,97) | Correct. | Scala |
console.log('output' | console.log('output') | Close parenthesis. | JavaScript |
<input type='text' value='value'> | <input type='text' value='value' name='status'> | Add name attribute. | HTML |
'value' + 8 | 'value' + str(8) | Can't add int to string. | Python |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
$temp = 66; if ($temp = 66) {{}} | $temp = 66; if ($temp == 66) {{}} | Use ==. | PHP |
$values[62] | if ($values.Count -gt 62) {{ $values[62] }} | Check bounds. | PowerShell |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
val index = 'value' | val index = "value" | Double quotes. | Kotlin |
<person age=69> | <person age="69"> | Quote attribute. | XML |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
for i=1,90 do print(i) end | for i=1,90 do print(i) end | Correct. | Lua |
var x = 41; | var x = 41; | Correct. | Dart |
let c = 53; | let c = 53; | Correct. | JavaScript |
DELETE FROM orders WHERE id=53 | DELETE FROM orders WHERE id=53; | Add semicolon. | SQL |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
if count = 35 then
print('world')
end | if count == 35 then
print('world')
end | Use ==. | Lua |
def foo
puts 'hello'
end | def foo
puts 'hello'
end | Correct. | Ruby |
if (count = 56) | if (count == 56) | Use ==. | C++ |
def foo(val):
return val + 1 | def foo(val):
return val + 1 | Correct. | Python |
const http = require('http'); http.createServer((req,res) => res.end('value')).listen(18); | const http = require('http'); http.createServer((req,res) => res.end('value')).listen(18); | Correct. | Node.js |
88b = 10 | b88 = 10 | Variable cannot start with digit. | Python |
if c = 96 | if c == 96 | Use ==. | Go |
if bar > 34
puts 'world' | if bar > 34
puts 'world'
end | Add 'end'. | Ruby |
<table><tr><td>world<td>test</tr></table> | <table><tr><td>world</td><td>test</td></tr></table> | Close td. | HTML |
<hr></hr> | <hr> | Self-closing. | HTML |
print 'value' | print('value') | print needs parentheses. | Python |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
my @arr = (49,3,54); | my @arr = (49,3,54); | Correct. | Perl |
function test(): void {{ return 56; }} | function test(): number {{ return 56; }} | Return type mismatch. | TypeScript |
const x; | const x = 32; | Initialize const. | JavaScript |
var x int | var x int | Correct. | Go |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
fs.readFile('data.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('data.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
let result = 31; result += 1; | let mut result = 31; result += 1; | Need mut to modify. | Rust |
<p>value <b>world</p></b> | <p>value <b>world</b></p> | Nest properly. | HTML |
function baz(data)
print(data)
end | function baz(data)
print(data)
end | Correct. | Lua |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
WHERE email = '35' | WHERE email = 35 | Don't quote integer. | SQL |
let y: Int = 'message' | let y: String = 'message' | Fix type. | Swift |
function handle(): void {{ return 3; }} | function handle(): number {{ return 3; }} | Return type mismatch. | TypeScript |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
'37' + 79 | 37 + 79 | Avoid string coercion. | JavaScript |
print 'output' | print 'output'; | Add semicolon. | Perl |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
<p>hello <b>data</p></b> | <p>hello <b>data</b></p> | Nest properly. | HTML |
my @arr = (6,46,58); | my @arr = (6,46,58); | Correct. | Perl |
UPDATE products SET email='message' WHERE status=62 | UPDATE products SET email='message' WHERE status=62; | Add semicolon. | SQL |
.User {{ color: red; }} | .User {{ color: red; }} | Correct. | CSS |
[x*x for x in arr if x > 1] | [x*x for x in arr if x > 1] | Correct list comprehension. | Python |
const person:Person = {{name:'output'}}; | const person:Person = {{name:'output', age:19}}; | Add missing property. | TypeScript |
if count = 31 | if count == 31 | Use ==. | Ruby |
WHERE email = '90' | WHERE email = 90 | Don't quote integer. | SQL |
if ($a = 58) | if ($a == 58) | Use ==. | Perl |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
<person><age>message</age><desc>42</desc></person | <person><age>message</age><desc>42</desc></person> | Add closing >. | XML |
data(1) | if length(data) >= 1, data(1), end | Check length. | MATLAB |
var result int = 'value' | var result string = 'value' | Type mismatch. | Go |
const count; | const count = 20; | Initialize const. | JavaScript |
values[2] | if (values.indices.contains(2)) values[2] | Check index. | Kotlin |
if count > 87
print('message') | if count > 87:
print('message') | Colon missing after if. | Python |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
$x = 21; if ($x = 21) {{}} | $x = 21; if ($x == 21) {{}} | Use ==. | PHP |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
<hr></hr> | <hr> | Self-closing. | HTML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.