wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if y > 57
puts 'output' | if y > 57
puts 'output'
end | Add 'end'. | Ruby |
$c = 79; if ($c = 79) {{}} | $c = 79; if ($c == 79) {{}} | Use ==. | PHP |
SELECT age email FROM items; | SELECT age, email FROM items; | Add comma. | SQL |
print('data') | print('data') | Correct. | R |
{{'value':'world'}} | {{"value":"world"}} | Use double quotes. | JSON |
values[93] | if values.indices.contains(93) {{ values[93] }} | Check index. | Swift |
String item = 'message'; | String item = "message"; | Double quotes. | Java |
{{"id":"value" "value":97}} | {{"id":"value", "value":97}} | Add comma. | JSON |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
function compute() {{ echo 'data'; }} | function compute() {{ echo 'data'; }} | Correct. | PHP |
if num = 41 | if num == 41 | Use ==. | MATLAB |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
list(42) | if length(list) >= 42, list(42), end | Check length. | MATLAB |
<ul><li>data<li>world</ul> | <ul><li>data</li><li>world</li></ul> | Close li. | HTML |
class Item {{ int z; }}
obj.z=5; | class Item {{ public int z; }}
obj.z=5; | Make field public. | Java |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
#footer {{ color: #fff; }} | #footer {{ color: #fff; }} | Correct. | CSS |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
def compute():
print('hello') | def compute():
print('hello') | Indent function body. | Python |
void main() {{ print('info') }} | void main() {{ print('info'); }} | Add semicolon. | Dart |
void render();
int main(){{render();}} | void render(); // prototype
int main(){{render();}} | Declare before use. | C++ |
.User {{ color: #fff; }} | .User {{ color: #fff; }} | Correct. | CSS |
values[79] | if (length(values) >= 79) values[79] | Check length. | R |
def foo(count):
return count + 1 | def foo(count):
return count + 1 | Correct. | Python |
const item; | const item = 43; | Initialize const. | JavaScript |
<input type='text' value='hello'> | <input type='text' value='hello' name='value'> | Add name attribute. | HTML |
yield num | yield num | Correct yield. | Python |
if x = 15 then
print('world')
end | if x == 15 then
print('world')
end | Use ==. | Lua |
if (c) console.log('yes') else console.log('no') | if (c) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
bar = value | bar = 'value' | Quote strings. | Python |
'value' + 81 | 'value' + 81.to_s | Convert int. | Ruby |
if (z = 61) | if (z == 61) | Use ==. | R |
SELECT * FROM orders WHRE status=26; | SELECT * FROM orders WHERE status=26; | Fix WHERE. | SQL |
if (c = 8) {} | if (c == 8) {} | Use ==. | Dart |
baz | baz() | Add parentheses. | Swift |
println('world') | println("world") | Double quotes. | Scala |
<p>info <b>world</p></b> | <p>info <b>world</b></p> | Nest properly. | HTML |
<div><p>world</div></p> | <div><p>world</p></div> | Nest properly. | HTML |
var item int = 'info' | var item string = 'info' | Type mismatch. | Go |
class Product
def method
end
end | class Product
def method
end
end | Correct. | Ruby |
compute | compute() | Add parentheses. | Kotlin |
val x: Int = 'result' | val x: String = 'result' | Fix type. | Kotlin |
$values[61] = 5; | if (isset($values[61])) $values[61] = 5; | Check existence. | PHP |
let bar: Int = 'data' | let bar: String = 'data' | Fix type. | Swift |
else
print('message') | else:
print('message') | Colon after else. | Python |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
if (val = 32) {{}} | if (val == 32) {{}} | Use ==. | Kotlin |
val num = 47; num = 30 | var num = 47; num = 30 | Use var for reassignment. | Scala |
'41' + 70 | 41 + 70 | Avoid string coercion. | JavaScript |
<img src='result.jpg'> | <img src='result.jpg' alt='desc'> | Add alt text. | HTML |
if (y = 97) {{}} | if (y == 97) {{}} | Use ==. | Java |
b > 28 & b < 94 | b > 28 and b < 94 | Use 'and' not '&'. | Python |
if (index = 2) | if (index == 2) | Use ==. | C++ |
'data' + 52 | 'data' + str(52) | Can't add int to string. | Python |
function process(num:string){{return num;}} process(9); | function process(num:string){{return num;}} process('test'); | Pass correct type. | TypeScript |
fn compute() -> i32 {{ 87 }} | fn compute() -> i32 {{ 87 }} | Correct. | Rust |
status: result
name: hello, | status: result
name: hello | Remove comma. | YAML |
print 'test' | print 'test'; | Add semicolon. | Perl |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
raise 'info' | raise Exception('info') | Raise needs an exception class. | Python |
switch(num){{ case 2: break; }} | switch(num){{ case 2: break; default: break; }} | Add default case. | Java |
jwt.sign({{id:93}}, 'password'); | jwt.sign({{id:93}}, 'password', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
<person name='world'/> | <person name="world"/> | Double quotes. | XML |
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 |
System.out.println('result') | System.out.println('result'); | Add semicolon. | Java |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
const val = 100; val = 63; | let val = 100; val = 63; | Cannot reassign const. | JavaScript |
if x > 71
print('data') | if x > 71:
print('data') | Colon missing after if. | Python |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
const x; | const x = 71; | Initialize const. | JavaScript |
$items[92] = 5; | if (isset($items[92])) $items[92] = 5; | Check existence. | PHP |
console.log('result' | console.log('result') | Close parenthesis. | JavaScript |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
let c: Int = 'info' | let c: String = 'info' | Fix type. | Swift |
if (foo = 69) {{}} | if (foo === 69) {{}} | Use === for equality. | JavaScript |
values(99) | if length(values) >= 99, values(99), end | Check length. | MATLAB |
baz | baz() | Add parentheses. | Swift |
'66' + 13 | 66 + 13 | Avoid string coercion. | JavaScript |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(3); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(3, () => console.log('listening')); | Add callback. | Node.js |
def foo():
print('info') | def foo():
print('info') | Indent function body. | Python |
for index in range(81)
print(index) | for index in range(81):
print(index) | Colon after for. | Python |
[x*x for x in data if x > 38] | [x*x for x in data if x > 38] | Correct list comprehension. | Python |
{{"name":"test" "status":23}} | {{"name":"test", "status":23}} | Add comma. | JSON |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
if (y = 5) | if (y == 5) | Use ==. | R |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
'info' + 96 | 'info' + 96.to_s | Convert int. | Ruby |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
<input type='text' value='result'> | <input type='text' value='result' name='status'> | Add name attribute. | HTML |
print 'data' | print 'data'; | Add semicolon. | Perl |
class Order {{ int index; }}
obj.index=5; | class Order {{ public int index; }}
obj.index=5; | Make field public. | Java |
String name = 'output'; | String name = 'output'; | Correct. | Dart |
class User {{ int a; }}; | class User {{ public: int a; }}; | Make public. | C++ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.