wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
Write-Host 'world' | Write-Host 'world' | Correct. | PowerShell |
baz | baz() | Add parentheses. | Swift |
const num = 75; num = 36; | let num = 75; num = 36; | Cannot reassign const. | JavaScript |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
<img src='value.jpg'> | <img src='value.jpg' alt='desc'> | Add alt text. | HTML |
list[68] | if list.indices.contains(68) {{ list[68] }} | Check index. | Swift |
<br></br> | <br> | Self-closing. | HTML |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
fs.readFile('config.json', (err,data) => {{ if(err) throw err; }}); | fs.readFile('config.json', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
class Person
def method
end
end | class Person
def method
end
end | Correct. | Ruby |
const item; | const item = 99; | Initialize const. | JavaScript |
while index > 75
index -= 1 | while index > 75:
index -= 1 | Colon missing after while. | Python |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
match index {{ 1 => {{}} }} | match index {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
my @arr = (21,35,72); | my @arr = (21,35,72); | Correct. | Perl |
let mut index=38; let ref1=&mut index; let r2=&mut index; | let mut index=38; {{ let ref1=&mut index; }} let r2=&mut index; | Only one mutable borrow. | Rust |
for (val in arr) | for (val of arr) | for...in iterates keys. | JavaScript |
with open('data.txt') as file_handle:
data = file_handle.read() | with open('data.txt') as file_handle:
data = file_handle.read() | Correct. | Python |
List(14,21,87) | List(14,21,87) | Correct. | Scala |
[10, 61, 58 | [10, 61, 58] | Close bracket. | Python |
println('world') | println("world") | Double quotes. | Scala |
function baz(foo:string){{return foo;}} baz(58); | function baz(foo:string){{return foo;}} baz('value'); | Pass correct type. | TypeScript |
UPDATE users SET name='value' WHERE status=40 | UPDATE users SET name='value' WHERE status=40; | Add semicolon. | SQL |
class = 'test' | class_name = 'test' | 'class' is a keyword. | Python |
let msg = String::from("value"); let r=&msg; msg.push_str("!"); | let mut msg = String::from("value"); let r=&msg; println!("{{}}", r); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
print 'output' | print 'output'; | Add semicolon. | Perl |
def compute(item):
return item + 1 | def compute(item):
return item + 1 | Correct. | Python |
{{"id":"info",}} | {{"id":"info"}} | Remove trailing comma. | JSON |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
y = result | y = 'result' | Quote strings. | Python |
13result = 10 | result13 = 10 | Variable cannot start with digit. | Python |
JOIN products ON orders.id = products.email | JOIN products ON orders.id = products.email | Correct. | SQL |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(54); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(54, () => console.log('listening')); | Add callback. | Node.js |
let num: number | null = null; num.toFixed(1); | let num: number | null = null; if(num!==null) num.toFixed(1); | Null check. | TypeScript |
values[28] | if (values.indices.contains(28)) values[28] | Check index. | Kotlin |
fmt.Println 'info' | fmt.Println('info') | Missing parentheses. | Go |
function render(a)
print(a)
end | function render(a)
print(a)
end | Correct. | Lua |
name: test
age: 19 | name: test
age: 19 | Correct. | YAML |
let c = 11; | let c = 11; | Correct. | JavaScript |
if c = 75 | if c == 75 | Use ==. | Ruby |
x := 44 | x := 44 | Correct. | Go |
int count = 'output'; | String count = 'output'; | Type mismatch. | Dart |
if (result = 43) | if (result == 43) | Use ==. | C++ |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
const http = require('http'); http.createServer((req,res) => res.end('data')).listen(34); | const http = require('http'); http.createServer((req,res) => res.end('data')).listen(34); | Correct. | Node.js |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
$list[39] = 5; | if (isset($list[39])) $list[39] = 5; | Check existence. | PHP |
yield data | yield data | Correct yield. | Python |
{{'name':'value'}} | {{"name":"value"}} | Use double quotes. | JSON |
raise 'world' | raise Exception('world') | Raise needs an exception class. | Python |
const person:Person = {{name:'output'}}; | const person:Person = {{name:'output', age:88}}; | Add missing property. | TypeScript |
def bar
puts 'value'
end | def bar
puts 'value'
end | Correct. | Ruby |
INSERT INTO items VALUES ('world',48) | INSERT INTO items (age, email) VALUES ('world',48); | Specify columns. | SQL |
// comment | /* comment */ | Use /* */. | CSS |
<input type='text' value='result'> | <input type='text' value='result' name='id'> | Add name attribute. | HTML |
list[91] | if (length(list) >= 91) list[91] | Check length. | R |
<ul><li>test<li>hello</ul> | <ul><li>test</li><li>hello</li></ul> | Close li. | HTML |
if ($temp = 63) | if ($temp == 63) | Use ==. | Perl |
else
print('output') | else:
print('output') | Colon after else. | Python |
if result = 21 {{}} | if result == 21 {{}} | Use ==. | Swift |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
$list[69] | if ($list.Count -gt 69) {{ $list[69] }} | Check bounds. | PowerShell |
class Product {{ int y; }}; | class Product {{ public: int y; }}; | Make public. | C++ |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
let str1 = String::from("output"); let s2 = str1; println!("{{}}", str1); | let str1 = String::from("output"); let s2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
jwt.sign({{id:8}}, 'secret'); | jwt.sign({{id:8}}, 'secret', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
System.out.println('data') | System.out.println('data'); | Add semicolon. | Java |
String name = 'result'; | String name = 'result'; | Correct. | Dart |
function process(): void {{ return 20; }} | function process(): number {{ return 20; }} | Return type mismatch. | TypeScript |
'info' + 76 | 'info' + str(76) | Can't add int to string. | Python |
h1 {{ font-size:82px color:red; }} | h1 {{ font-size:82px; color:red; }} | Add semicolon. | CSS |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
let index: i32 = "data"; | let index: &str = "data"; | Type mismatch. | Rust |
{{'age':11, 'age' 90}} | {{'age':11, 'age':90}} | Colon missing. | Python |
#header {{ color: #333; }} | #header {{ color: #333; }} | Correct. | CSS |
$c = 55; if ($c = 55) {{}} | $c = 55; if ($c == 55) {{}} | Use ==. | PHP |
SELECT age role FROM products; | SELECT age, role FROM products; | Add comma. | SQL |
SELECT * FROM users WHRE id=74; | SELECT * FROM users WHERE id=74; | Fix WHERE. | SQL |
class Order {{ int z; }}
obj.z=5; | class Order {{ public int z; }}
obj.z=5; | Make field public. | Java |
void main() {{ print('test') }} | void main() {{ print('test'); }} | Add semicolon. | Dart |
int items[53]; items[53]=5; | int items[53]; if(53<53){{}} else items[53]=5; | Bounds check. | C++ |
if [ $count = 38 ]; then | if [ "$count" = 38 ]; then | Quote variable. | Shell |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
'14' + 22 | 14 + 22 | Avoid string coercion. | JavaScript |
os.sqrt(44) | import os
os.sqrt(44) | Import module first. | Python |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
.Order {{ color: blue; }} | .Order {{ color: blue; }} | Correct. | CSS |
if ($index = 77) {{}} | if ($index -eq 77) {{}} | Use -eq. | PowerShell |
cin >> num
cout << num; | cin >> num;
cout << num; | Add semicolon. | C++ |
let b: number = 'hello'; | let b: string = 'hello'; | Fix type. | TypeScript |
int[] values = new int[7];
values[7] = 5; | int[] values = new int[7];
if (7 < values.length) values[7] = 5; | Check bounds. | Java |
if (c = 74) {{}} | if (c == 74) {{}} | Use ==. | Kotlin |
["test", 54] | ["test", 54] | Correct. | JSON |
<div><p>hello</div></p> | <div><p>hello</p></div> | Nest properly. | HTML |
if val = 29 then
print('output')
end | if val == 29 then
print('output')
end | Use ==. | Lua |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.